Last active
September 12, 2023 20:22
-
-
Save mlaflamm/5093c5877b401f608a1a737fab7b662c to your computer and use it in GitHub Desktop.
Revisions
-
mlaflamm revised this gist
Apr 21, 2021 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,7 @@ # 'rm' and 'mv' are for flattening the deep directory structure rm -rf jetdb model table jet -source=PostgreSQL -host=localhost -port=5432 -user=jetuser -password=jetpass -dbname=jetdb -schema=dvds -path=. mv ./jetdb/dvds/* . rm -rf jetdb @@ -32,4 +32,4 @@ else fi # this is to remove unused import packages find ./model -type f -name '*.go' | xargs goimports -w -
mlaflamm revised this gist
Nov 23, 2020 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -13,12 +13,16 @@ rm */schema_migrations.go if [ "$(uname)" == "Darwin" ]; then find ./model -type f -name '*.go' | xargs sed -i '' -e 's|int32|int|g' find ./model -type f -name '*.go' | xargs sed -i '' -e 's|*int|null.Int|g' find ./model -type f -name '*.go' | xargs sed -i '' -e 's|*float64|null.String|g' find ./model -type f -name '*.go' | xargs sed -i '' -e 's|float64|string|g' find ./model -type f -name '*.go' | xargs sed -i '' -e 's|*string|null.String|g' find ./model -type f -name '*.go' | xargs sed -i '' -e 's|*time.Time|null.Time|g' find ./model -type f -name '*.go' | xargs sed -i '' -e 's|package model|package model\'$'\nimport "github.com/volatiletech/null/v8"|g' elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then find ./model -type f -name '*.go' | xargs sed -i 's|int32|int|g' find ./model -type f -name '*.go' | xargs sed -i 's|*int|null.Int|g' find ./model -type f -name '*.go' | xargs sed -i 's|*float64|null.String|g' find ./model -type f -name '*.go' | xargs sed -i 's|float64|string|g' find ./model -type f -name '*.go' | xargs sed -i 's|*string|null.String|g' find ./model -type f -name '*.go' | xargs sed -i 's|*time.Time|null.Time|g' find ./model -type f -name '*.go' | xargs sed -i 's|package model|package model\n\nimport "github.com/volatiletech/null/v8"|g' -
mlaflamm revised this gist
Nov 21, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -27,5 +27,5 @@ else exit 1 fi # this is to remove unused import packages find ./model -type f -name '*.go' | xargs go run golang.org/x/tools/cmd/goimports -w -
mlaflamm revised this gist
Nov 21, 2020 . 2 changed files with 4 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,9 +12,10 @@ Yes this is possible to revert to raw SQL but then we lose some of the type safe When we discovered `go-jet`, we were very excited. A type safe SQL builder solution with code generation is exactly what we were looking for! Our only gripe was the usage of pointers for nullable values instead of the convenient `null` types. You can use different types if you provide you own custom models but we really wants to use the generated models. After tinkering with multiple ways to generate `go-jet` models with `null` types, we ended up wrapping the jet code generator with a bash script that automatically converts the types of the `go-jet` models to our beloved `null` types. Here is the bash wrapper in its full glory. This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ #!/bin/bash # 'rm' and 'mv' are for flattening the deep directory structure rm -rf jetdb model table go run github.com/go-jet/jet/v2/cmd/jet -source=PostgreSQL -host=localhost -port=5432 -user=jetuser -password=jetpass -dbname=jetdb -schema=dvds -path=. mv ./jetdb/dvds/* . -
mlaflamm revised this gist
Nov 16, 2020 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -15,4 +15,6 @@ A type safe SQL builder solution with code generation is exactly what we were lo Our only complaint was the usage of pointers for nullable values instead of the convenient `null` types. After tinkering with multiple ways to generate `go-jet` models with `null` types, we ended up wrapping the jet code generator with a bash script that automatically converts the types of the `go-jet` models to our beloved `null` types. Here it is in its full glory. -
mlaflamm revised this gist
Nov 16, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,7 @@ As far as we know, this is the only solution that fully supports mapping of `LEF We have used straight [sql package](https://golang.org/pkg/database/sql/), [sqlx](https://github.com/jmoiron/sqlx), [squirrel](https://github.com/Masterminds/squirrel) with and without `sqlx`, and more recently [sqlboiler](https://github.com/volatiletech/sqlboiler). The latter is an ORM rather than an SQL builder but we love the type safety with code generation. Also their [null](https://github.com/volatiletech/null) types package is a breeze to work with. But over time, `sqlboiler` being an ORM, showed its limitations in terms of performance and flexibility. Yes this is possible to revert to raw SQL but then we lose some of the type safety. -
mlaflamm revised this gist
Nov 16, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ We love [go-jet](https://github.com/go-jet/jet)! We are now using it or migrating it to, in all our projects. This is simply the best go SQL builder we have tried so far. It is type safe thanks to the code generation and the [query result mapping](https://github.com/go-jet/jet/wiki/Query-Result-Mapping-(QRM)) is very powerful. As far as we know, this is the only solution that fully supports mapping of `LEFT OUTER JOIN` out of the box. We have used straight [sql package](https://golang.org/pkg/database/sql/), [sqlx](https://github.com/jmoiron/sqlx), [squirrel](https://github.com/Masterminds/squirrel) -
mlaflamm revised this gist
Nov 16, 2020 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,12 +6,12 @@ As far as we know, this is the only solution that fully supports mapping of `LEF We have used straight [sql package](https://golang.org/pkg/database/sql/), [sqlx](https://github.com/jmoiron/sqlx), [squirrel](https://github.com/Masterminds/squirrel) with and without `sqlx`, and more recently [sqlboiler](https://github.com/volatiletech/sqlboiler). The latter is an ORM rather than an SQL builder but we loved the type safety with code generation. Also their [null](https://github.com/volatiletech/null) types package is a breeze to work with. But over time, `sqlboiler` being an ORM, showed its limitations in terms of performance and flexibility. Yes this is possible to revert to raw SQL but then we lose some of the type safety. When we discovered `go-jet`, we were very excited. A type safe SQL builder solution with code generation is exactly what we were looking for! Our only complaint was the usage of pointers for nullable values instead of the convenient `null` types. After tinkering with multiple ways to generate `go-jet` models with `null` types, we ended up wrapping the jet code generator with a bash script -
mlaflamm revised this gist
Nov 16, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,5 +14,5 @@ When we discovered `go-jet`, we were very excited. A type safe SQL builder solution is exactly what we were looking for! Our only complaint was the usage of pointers for nullable values instead of the convenient `null` types. After tinkering with multiple ways to generate `go-jet` models with `null` types, we ended up wrapping the jet code generator with a bash script that automatically converts the types of the `go-jet` models to our beloved `null` types. -
mlaflamm revised this gist
Nov 16, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ We love [go-jet](https://github.com/go-jet/jet)! We are now using it or migrating it to, in all our projects. This is simply the best go SQL builder we have tried so far. It is type safe thanks to the code generation and the query result mapping is very powerful. As far as we know, this is the only solution that fully supports mapping of `LEFT OUTER JOIN` out of the box. We have used straight [sql package](https://golang.org/pkg/database/sql/), [sqlx](https://github.com/jmoiron/sqlx), [squirrel](https://github.com/Masterminds/squirrel) with and without `sqlx`, and more recently [sqlboiler](https://github.com/volatiletech/sqlboiler). -
mlaflamm revised this gist
Nov 16, 2020 . 1 changed file with 3 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,14 +1,15 @@ #!/bin/bash # 'rm' and 'mv' are for flattening the annoyingly deep directory structure rm -rf jetdb model table go run github.com/go-jet/jet/v2/cmd/jet -source=PostgreSQL -host=localhost -port=5432 -user=jetuser -password=jetpass -dbname=jetdb -schema=dvds -path=. mv ./jetdb/dvds/* . rm -rf jetdb # this is how we exclude tables rm */schema_migrations.go # this is the main replacement 'logic' if [ "$(uname)" == "Darwin" ]; then find ./model -type f -name '*.go' | xargs sed -i '' -e 's|int32|int|g' find ./model -type f -name '*.go' | xargs sed -i '' -e 's|*int|null.Int|g' -
mlaflamm created this gist
Nov 16, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ We love [go-jet](https://github.com/go-jet/jet)! We are now using it or migrating it to, in all our projects. This is simply the best go SQL builder we have tried so far. It is type safe thanks to the code generation and the query result mapping is very powerful. As far as we know, this is the only solution that fully supports mapping of LEFT OUTER JOIN out of the box. We have used straight [sql package](https://golang.org/pkg/database/sql/), [sqlx](https://github.com/jmoiron/sqlx), [squirrel](https://github.com/Masterminds/squirrel) with and without `sqlx`, and more recently [sqlboiler](https://github.com/volatiletech/sqlboiler). The latter is an ORM rather than an SQL builder but we loved the type safety with code generation. Also their [null](https://github.com/volatiletech/null) types package are a breeze to work with. But over time, `sqlboiler` being an ORM, showed its limitations in terms of performance and flexibility. Yes this is possible to revert to raw SQL but then we lose some of the type safety. When we discovered `go-jet`, we were very excited. A type safe SQL builder solution is exactly what we were looking for! Our only complaint was the usage of pointers for nullable values instead of the convenient `null` types. After tinkering with multiple solutions, we ended up wrapping the jet code generator with a bash script that automatically converts the types of the `go-jet` models to our beloved `null` types. This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ #!/bin/bash # 'rm' and 'mv' are for flattening the directory structure rm -rf jetdb model table go run github.com/go-jet/jet/v2/cmd/jet -source=PostgreSQL -host=localhost -port=5432 -user=jetuser -password=jetpass -dbname=jetdb -schema=dvds -path=. mv ./jetdb/dvds/* . rm -rf jetdb # this how we exclude tables rm */schema_migrations.go if [ "$(uname)" == "Darwin" ]; then find ./model -type f -name '*.go' | xargs sed -i '' -e 's|int32|int|g' find ./model -type f -name '*.go' | xargs sed -i '' -e 's|*int|null.Int|g' find ./model -type f -name '*.go' | xargs sed -i '' -e 's|*string|null.String|g' find ./model -type f -name '*.go' | xargs sed -i '' -e 's|*time.Time|null.Time|g' find ./model -type f -name '*.go' | xargs sed -i '' -e 's|package model|package model\'$'\nimport "github.com/volatiletech/null/v8"|g' elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then find ./model -type f -name '*.go' | xargs sed -i 's|int32|int|g' find ./model -type f -name '*.go' | xargs sed -i 's|*int|null.Int|g' find ./model -type f -name '*.go' | xargs sed -i 's|*string|null.String|g' find ./model -type f -name '*.go' | xargs sed -i 's|*time.Time|null.Time|g' find ./model -type f -name '*.go' | xargs sed -i 's|package model|package model\n\nimport "github.com/volatiletech/null/v8"|g' else echo "platform $OSTYPE not supported" exit 1 fi # this is to removes unused import packages find ./model -type f -name '*.go' | xargs go run golang.org/x/tools/cmd/goimports -w