Skip to content

Automatically escape '.' in table names #1257

Open
@Tassil0

Description

@Tassil0

What version of SQLBoiler are you using (sqlboiler --version)?

SQLBoiler v4.14.1

What is your database and version (eg. Postgresql 10)

SQLBoiler v4.14.1

If this happened at generation time what was the full SQLBoiler command you used to generate your models? (if not applicable leave blank)

sqlboiler psql

What is the output of the command above with the -d flag added to it? (Provided you are comfortable sharing this, it contains a blueprint of your schema)

using driver: /Users/tassilo/go/bin/darwin_amd64/sqlboiler-psql
{"config":{"driver_name":"psql","driver_config":{"add-enum-types":false,"blacklist":null,"dbname":"bazos","enum-null-prefix":"Null","host":"localhost","pass":"kokos","port":5420,"sslmode":"disable","user":"bazos","whitelist":null},"pkg_name":"models","out_folder":"models","debug":true,"enum_null_prefix":"Null","struct_tag_casing":"snake","relation_tag":"-","imports":{"all":{"Standard":["\"database/sql\"","\"fmt\"","\"reflect\"","\"strconv\"","\"strings\"","\"sync\"","\"time\"","\"context\""],"ThirdParty":["\"github.com/friendsofgo/errors\"","\"github.com/volatiletech/sqlboiler/v4/boil\"","\"github.com/volatiletech/sqlboiler/v4/queries\"","\"github.com/volatiletech/sqlboiler/v4/queries/qm\"","\"github.com/volatiletech/sqlboiler/v4/queries/qmhelper\"","\"github.com/volatiletech/strmangle\""]},"test":{"Standard":["\"bytes\"","\"reflect\"","\"testing\"","\"context\""],"ThirdParty":["\"github.com/volatiletech/randomize\"","\"github.com/volatiletech/sqlboiler/v4/boil\"","\"github.com/volatiletech/sqlboiler/v4/queries\"","\"github.com/volatiletech/strmangle\""]},"singleton":{"boil_queries":{"Standard":null,"ThirdParty":["\"github.com/volatiletech/sqlboiler/v4/drivers\"","\"github.com/volatiletech/sqlboiler/v4/queries\"","\"github.com/volatiletech/sqlboiler/v4/queries/qm\""]},"boil_types":{"Standard":["\"strconv\""],"ThirdParty":["\"github.com/friendsofgo/errors\"","\"github.com/volatiletech/sqlboiler/v4/boil\"","\"github.com/volatiletech/strmangle\""]},"psql_upsert":{"Standard":["\"fmt\"","\"strings\""],"ThirdParty":["\"github.com/volatiletech/sqlboiler/v4/drivers\"","\"github.com/volatiletech/strmangle\""]}},"test_singleton":{"boil_main_test":{"Standard":["\"database/sql\"","\"flag\"","\"fmt\"","\"math/rand\"","\"os\"","\"path/filepath\"","\"strings\"","\"testing\"","\"time\""],"ThirdParty":["\"github.com/spf13/viper\"","\"github.com/volatiletech/sqlboiler/v4/boil\""]},"boil_queries_test":{"Standard":["\"bytes\"","\"fmt\"","\"io\"","\"math/rand\"","\"regexp\""],"ThirdParty":["\"github.com/volatiletech/sqlboiler/v4/boil\""]},"boil_suites_test":{"Standard":["\"testing\""],"ThirdParty":null},"psql_main_test":{"Standard":["\"bytes\"","\"database/sql\"","\"fmt\"","\"io\"","\"os\"","\"os/exec\"","\"regexp\"","\"strings\""],"ThirdParty":["\"github.com/friendsofgo/errors\"","\"github.com/kat-co/vala\"","_ \"github.com/lib/pq\"","\"github.com/spf13/viper\"","\"github.com/volatiletech/randomize\"","\"github.com/volatiletech/sqlboiler/v4/drivers/sqlboiler-psql/driver\""]},"psql_suites_test":{"Standard":["\"testing\""],"ThirdParty":[]}},"based_on_type":{"null.Bool":{"Standard":[],"ThirdParty":["\"github.com/volatiletech/null/v8\""]},"null.Bytes":{"Standard":[],"ThirdParty":["\"github.com/volatiletech/null/v8\""]},"null.Float32":{"Standard":[],"ThirdParty":["\"github.com/volatiletech/null/v8\""]},"null.Float64":{"Standard":[],"ThirdParty":["\"github.com/volatiletech/null/v8\""]},"null.Int":{"Standard":[],"ThirdParty":["\"github.com/volatiletech/null/v8\""]},"null.Int16":{"Standard":[],"ThirdParty":["\"github.com/volatiletech/null/v8\""]},"null.Int32":{"Standard":[],"ThirdParty":["\"github.com/volatiletech/null/v8\""]},"null.Int64":{"Standard":[],"ThirdParty":["\"github.com/volatiletech/null/v8\""]},"null.Int8":{"Standard":[],"ThirdParty":["\"github.com/volatiletech/null/v8\""]},"null.JSON":{"Standard":[],"ThirdParty":["\"github.com/volatiletech/null/v8\""]},"null.String":{"Standard":[],"ThirdParty":["\"github.com/volatiletech/null/v8\""]},"null.Time":{"Standard":[],"ThirdParty":["\"github.com/volatiletech/null/v8\""]},"null.Uint":{"Standard":[],"ThirdParty":["\"github.com/volatiletech/null/v8\""]},"null.Uint16":{"Standard":[],"ThirdParty":["\"github.com/volatiletech/null/v8\""]},"null.Uint32":{"Standard":[],"ThirdParty":["\"github.com/volatiletech/null/v8\""]},"null.Uint64":{"Standard":[],"ThirdParty":["\"github.com/volatiletech/null/v8\""]},"null.Uint8":{"Standard":[],"ThirdParty":["\"github.com/volatiletech/null/v8\""]},"pgeo.Box":{"Standard":[],"ThirdParty":["\"github.com/volatiletech/sqlboiler/v4/types/pgeo\""]},"pgeo.Circle":{"Standard":[],"ThirdParty":["\"github.com/volatiletech/sqlboiler/v4/types/pgeo\""]},"pgeo.Line":{"Standard":[],"ThirdParty":["\"github.com/volatiletech/sqlboiler/v4/types/pgeo\""]},"pgeo.Lseg":{"Standard":[],"ThirdParty":["\"github.com/volatiletech/sqlboiler/v4/types/pgeo\""]},"pgeo.NullBox":{"Standard":[],"ThirdParty":["\"github.com/volatiletech/sqlboiler/v4/types/pgeo\""]},"pgeo.NullCircle":{"Standard":[],"ThirdParty":["\"github.com/volatiletech/sqlboiler/v4/types/pgeo\""]},"pgeo.NullLine":{"Standard":[],"ThirdParty":["\"github.com/volatiletech/sqlboiler/v4/types/pgeo\""]},"pgeo.NullLseg":{"Standard":[],"ThirdParty":["\"github.com/volatiletech/sqlboiler/v4/types/pgeo\""]},"pgeo.NullPath":{"Standard":[],"ThirdParty":["\"github.com/volatiletech/sqlboiler/v4/types/pgeo\""]},"pgeo.NullPoint":{"Standard":[],"ThirdParty":["\"github.com/volatiletech/sqlboiler/v4/types/pgeo\""]},"pgeo.NullPolygon":{"Standard":[],"ThirdParty":["\"github.com/volatiletech/sqlboiler/v4/types/pgeo\""]},"pgeo.Path":{"Standard":[],"ThirdParty":["\"github.com/volatiletech/sqlboiler/v4/types/pgeo\""]},"pgeo.Point":{"Standard":[],"ThirdParty":["\"github.com/volatiletech/sqlboiler/v4/types/pgeo\""]},"pgeo.Polygon":{"Standard":[],"ThirdParty":["\"github.com/volatiletech/sqlboiler/v4/types/pgeo\""]},"time.Time":{"Standard":["\"time\""],"ThirdParty":[]},"types.BoolArray":{"Standard":[],"ThirdParty":["\"github.com/volatiletech/sqlboiler/v4/types\""]},"types.BytesArray":{"Standard":[],"ThirdParty":["\"github.com/volatiletech/sqlboiler/v4/types\""]},"types.Decimal":{"Standard":[],"ThirdParty":["\"github.com/volatiletech/sqlboiler/v4/types\""]},"types.DecimalArray":{"Standard":[],"ThirdParty":["\"github.com/volatiletech/sqlboiler/v4/types\""]},"types.Float64Array":{"Standard":[],"ThirdParty":["\"github.com/volatiletech/sqlboiler/v4/types\""]},"types.HStore":{"Standard":[],"ThirdParty":["\"github.com/volatiletech/sqlboiler/v4/types\""]},"types.Int64Array":{"Standard":[],"ThirdParty":["\"github.com/volatiletech/sqlboiler/v4/types\""]},"types.JSON":{"Standard":[],"ThirdParty":["\"github.com/volatiletech/sqlboiler/v4/types\""]},"types.NullDecimal":{"Standard":[],"ThirdParty":["\"github.com/volatiletech/sqlboiler/v4/types\""]},"types.StringArray":{"Standard":[],"ThirdParty":["\"github.com/volatiletech/sqlboiler/v4/types\""]}}},"aliases":{"tables":{"public.items":{"up_plural":"PublicItems","up_singular":"PublicItem","down_plural":"public.items","down_singular":"public.item","columns":{"blacklisted":"Blacklisted","date_added":"DateAdded","description":"Description","id":"ID","img":"Img","last_updated":"LastUpdated","location":"Location","name":"Name","price":"Price","query_id":"QueryID","url":"URL"}},"public.queries":{"up_plural":"PublicQueries","up_singular":"PublicQuery","down_plural":"public.queries","down_singular":"public.query","columns":{"filter_city":"FilterCity","filter_price_high":"FilterPriceHigh","filter_price_low":"FilterPriceLow","id":"ID","query":"Query"}}}},"auto_columns":{},"inflections":{"Plural":{},"PluralExact":{},"Singular":{},"SingularExact":{},"Irregular":{}},"version":"4.14.1"},"driver_config":{"add-enum-types":false,"blacklist":null,"dbname":"bazos","enum-null-prefix":"Null","host":"localhost","pass":"kokos","port":5420,"sslmode":"disable","user":"bazos","whitelist":null},"schema":"public","dialect":{"lq":34,"rq":34,"use_index_placeholders":true,"use_last_insert_id":false,"use_schema":false,"use_default_keyword":true,"use_top_clause":false,"use_output_clause":false,"use_case_when_exists_clause":false,"use_auto_columns":false},"tables":[{"name":"public.items","schema_name":"","columns":[{"name":"id","type":"int","db_type":"integer","default":"nextval('\"public.items_id_seq\"'::regclass)","comment":"","nullable":false,"unique":true,"validated":false,"auto_generated":false,"arr_type":null,"udt_name":"int4","domain_name":null,"full_db_type":"int4"},{"name":"name","type":"string","db_type":"text","default":"","comment":"","nullable":false,"unique":false,"validated":false,"auto_generated":false,"arr_type":null,"udt_name":"text","domain_name":null,"full_db_type":"text"},{"name":"description","type":"string","db_type":"text","default":"","comment":"","nullable":false,"unique":false,"validated":false,"auto_generated":false,"arr_type":null,"udt_name":"text","domain_name":null,"full_db_type":"text"},{"name":"price","type":"int","db_type":"integer","default":"","comment":"","nullable":false,"unique":false,"validated":false,"auto_generated":false,"arr_type":null,"udt_name":"int4","domain_name":null,"full_db_type":"int4"},{"name":"img","type":"string","db_type":"text","default":"","comment":"","nullable":false,"unique":false,"validated":false,"auto_generated":false,"arr_type":null,"udt_name":"text","domain_name":null,"full_db_type":"text"},{"name":"location","type":"string","db_type":"text","default":"","comment":"","nullable":false,"unique":false,"validated":false,"auto_generated":false,"arr_type":null,"udt_name":"text","domain_name":null,"full_db_type":"text"},{"name":"url","type":"string","db_type":"text","default":"","comment":"","nullable":false,"unique":false,"validated":false,"auto_generated":false,"arr_type":null,"udt_name":"text","domain_name":null,"full_db_type":"text"},{"name":"blacklisted","type":"bool","db_type":"boolean","default":"","comment":"","nullable":false,"unique":false,"validated":false,"auto_generated":false,"arr_type":null,"udt_name":"bool","domain_name":null,"full_db_type":"bool"},{"name":"date_added","type":"time.Time","db_type":"date","default":"","comment":"","nullable":false,"unique":false,"validated":false,"auto_generated":false,"arr_type":null,"udt_name":"date","domain_name":null,"full_db_type":"date"},{"name":"last_updated","type":"time.Time","db_type":"timestamp without time zone","default":"","comment":"","nullable":false,"unique":false,"validated":false,"auto_generated":false,"arr_type":null,"udt_name":"timestamp","domain_name":null,"full_db_type":"timestamp"},{"name":"query_id","type":"int","db_type":"integer","default":"","comment":"","nullable":false,"unique":false,"validated":false,"auto_generated":false,"arr_type":null,"udt_name":"int4","domain_name":null,"full_db_type":"int4"}],"p_key":{"name":"items_pk","columns":["id"]},"f_keys":null,"is_join_table":false,"to_one_relationships":null,"to_many_relationships":null,"is_view":false,"view_capabilities":{"can_insert":false,"can_upsert":false}},{"name":"public.queries","schema_name":"","columns":[{"name":"id","type":"int","db_type":"integer","default":"nextval('\"public.queries_id_seq\"'::regclass)","comment":"","nullable":false,"unique":true,"validated":false,"auto_generated":false,"arr_type":null,"udt_name":"int4","domain_name":null,"full_db_type":"int4"},{"name":"query","type":"string","db_type":"text","default":"","comment":"","nullable":false,"unique":false,"validated":false,"auto_generated":false,"arr_type":null,"udt_name":"text","domain_name":null,"full_db_type":"text"},{"name":"filter_price_low","type":"null.Int","db_type":"integer","default":"NULL","comment":"","nullable":true,"unique":false,"validated":false,"auto_generated":false,"arr_type":null,"udt_name":"int4","domain_name":null,"full_db_type":"int4"},{"name":"filter_price_high","type":"null.Int","db_type":"integer","default":"NULL","comment":"","nullable":true,"unique":false,"validated":false,"auto_generated":false,"arr_type":null,"udt_name":"int4","domain_name":null,"full_db_type":"int4"},{"name":"filter_city","type":"null.String","db_type":"text","default":"NULL","comment":"","nullable":true,"unique":false,"validated":false,"auto_generated":false,"arr_type":null,"udt_name":"text","domain_name":null,"full_db_type":"text"}],"p_key":{"name":"queries_pk","columns":["id"]},"f_keys":null,"is_join_table":false,"to_one_relationships":null,"to_many_relationships":null,"is_view":false,"view_capabilities":{"can_insert":false,"can_upsert":false}}],"templates":[{"name":"main/00_struct.go.tpl","loader":"asset:main/00_struct.go.tpl"},{"name":"main/01_types.go.tpl","loader":"asset:main/01_types.go.tpl"},{"name":"main/02_hooks.go.tpl","loader":"asset:main/02_hooks.go.tpl"},{"name":"main/03_finishers.go.tpl","loader":"asset:main/03_finishers.go.tpl"},{"name":"main/04_relationship_to_one.go.tpl","loader":"asset:main/04_relationship_to_one.go.tpl"},{"name":"main/05_relationship_one_to_one.go.tpl","loader":"asset:main/05_relationship_one_to_one.go.tpl"},{"name":"main/06_relationship_to_many.go.tpl","loader":"asset:main/06_relationship_to_many.go.tpl"},{"name":"main/07_relationship_to_one_eager.go.tpl","loader":"asset:main/07_relationship_to_one_eager.go.tpl"},{"name":"main/08_relationship_one_to_one_eager.go.tpl","loader":"asset:main/08_relationship_one_to_one_eager.go.tpl"},{"name":"main/09_relationship_to_many_eager.go.tpl","loader":"asset:main/09_relationship_to_many_eager.go.tpl"},{"name":"main/10_relationship_to_one_setops.go.tpl","loader":"asset:main/10_relationship_to_one_setops.go.tpl"},{"name":"main/11_relationship_one_to_one_setops.go.tpl","loader":"asset:main/11_relationship_one_to_one_setops.go.tpl"},{"name":"main/12_relationship_to_many_setops.go.tpl","loader":"asset:main/12_relationship_to_many_setops.go.tpl"},{"name":"main/13_all.go.tpl","loader":"asset:main/13_all.go.tpl"},{"name":"main/14_find.go.tpl","loader":"asset:main/14_find.go.tpl"},{"name":"main/15_insert.go.tpl","loader":"asset:main/15_insert.go.tpl"},{"name":"main/16_update.go.tpl","loader":"asset:main/16_update.go.tpl"},{"name":"main/17_upsert.go.tpl","loader":"base64:(sha256 of content): 52fd3a5d952e511f6c2866d79fb418d1d348df36d4924c40bee6ce14cbc322bf"},{"name":"main/18_delete.go.tpl","loader":"asset:main/18_delete.go.tpl"},{"name":"main/19_reload.go.tpl","loader":"asset:main/19_reload.go.tpl"},{"name":"main/20_exists.go.tpl","loader":"asset:main/20_exists.go.tpl"},{"name":"main/21_auto_timestamps.go.tpl","loader":"asset:main/21_auto_timestamps.go.tpl"},{"name":"main/singleton/boil_queries.go.tpl","loader":"asset:main/singleton/boil_queries.go.tpl"},{"name":"main/singleton/boil_table_names.go.tpl","loader":"asset:main/singleton/boil_table_names.go.tpl"},{"name":"main/singleton/boil_types.go.tpl","loader":"asset:main/singleton/boil_types.go.tpl"},{"name":"main/singleton/boil_view_names.go.tpl","loader":"asset:main/singleton/boil_view_names.go.tpl"},{"name":"main/singleton/psql_upsert.go.tpl","loader":"base64:(sha256 of content): cb25b2a17877de034695accfb0a1f5f11437114d5f919062c792efee53cbb25f"},{"name":"test/00_types.go.tpl","loader":"asset:test/00_types.go.tpl"},{"name":"test/all.go.tpl","loader":"asset:test/all.go.tpl"},{"name":"test/delete.go.tpl","loader":"asset:test/delete.go.tpl"},{"name":"test/exists.go.tpl","loader":"asset:test/exists.go.tpl"},{"name":"test/find.go.tpl","loader":"asset:test/find.go.tpl"},{"name":"test/finishers.go.tpl","loader":"asset:test/finishers.go.tpl"},{"name":"test/hooks.go.tpl","loader":"asset:test/hooks.go.tpl"},{"name":"test/insert.go.tpl","loader":"asset:test/insert.go.tpl"},{"name":"test/relationship_one_to_one.go.tpl","loader":"asset:test/relationship_one_to_one.go.tpl"},{"name":"test/relationship_one_to_one_setops.go.tpl","loader":"asset:test/relationship_one_to_one_setops.go.tpl"},{"name":"test/relationship_to_many.go.tpl","loader":"asset:test/relationship_to_many.go.tpl"},{"name":"test/relationship_to_many_setops.go.tpl","loader":"asset:test/relationship_to_many_setops.go.tpl"},{"name":"test/relationship_to_one.go.tpl","loader":"asset:test/relationship_to_one.go.tpl"},{"name":"test/relationship_to_one_setops.go.tpl","loader":"asset:test/relationship_to_one_setops.go.tpl"},{"name":"test/reload.go.tpl","loader":"asset:test/reload.go.tpl"},{"name":"test/select.go.tpl","loader":"asset:test/select.go.tpl"},{"name":"test/singleton/boil_main_test.go.tpl","loader":"asset:test/singleton/boil_main_test.go.tpl"},{"name":"test/singleton/boil_queries_test.go.tpl","loader":"asset:test/singleton/boil_queries_test.go.tpl"},{"name":"test/singleton/boil_suites_test.go.tpl","loader":"asset:test/singleton/boil_suites_test.go.tpl"},{"name":"test/singleton/psql_main_test.go.tpl","loader":"base64:(sha256 of content): a10f31b033737bdec0142363f6661a201e39eee8201e6cd56f889278d9e05f80"},{"name":"test/singleton/psql_suites_test.go.tpl","loader":"base64:(sha256 of content): a89b312831433fa034ad26757c27224bad4cf17b2e1a89a31574c5da21f68fa7"},{"name":"test/types.go.tpl","loader":"asset:test/types.go.tpl"},{"name":"test/update.go.tpl","loader":"asset:test/update.go.tpl"},{"name":"test/upsert.go.tpl","loader":"base64:(sha256 of content): fbdedf7ee38269da51adf562f603fb1616cf5ac7975c53268a9181863b2c2258"}]}
Error: 194:12: expected type, found '.' (and 10 more errors)
failed to format template

 189 }{
 190 	
 191 }
 192 
 193 // public.itemR is where relationships are stored.
>>>> type public.itemR struct {
 195 	
 196 }
 197 
 198 // NewStruct creates a new relationship struct
 199 func (*public.itemR) NewStruct() *public.itemR {


github.com/volatiletech/sqlboiler/v4/boilingcore.formatBuffer
	/Users/tassilo/go/pkg/mod/github.com/volatiletech/sqlboiler/[email protected]/boilingcore/output.go:300
github.com/volatiletech/sqlboiler/v4/boilingcore.writeFile
	/Users/tassilo/go/pkg/mod/github.com/volatiletech/sqlboiler/[email protected]/boilingcore/output.go:240
github.com/volatiletech/sqlboiler/v4/boilingcore.executeTemplates
	/Users/tassilo/go/pkg/mod/github.com/volatiletech/sqlboiler/[email protected]/boilingcore/output.go:161
github.com/volatiletech/sqlboiler/v4/boilingcore.generateOutput
	/Users/tassilo/go/pkg/mod/github.com/volatiletech/sqlboiler/[email protected]/boilingcore/output.go:63
github.com/volatiletech/sqlboiler/v4/boilingcore.(*State).Run
	/Users/tassilo/go/pkg/mod/github.com/volatiletech/sqlboiler/[email protected]/boilingcore/boilingcore.go:197
main.run
	/Users/tassilo/go/pkg/mod/github.com/volatiletech/sqlboiler/[email protected]/main.go:260
github.com/spf13/cobra.(*Command).execute
	/Users/tassilo/go/pkg/mod/github.com/spf13/[email protected]/command.go:872
github.com/spf13/cobra.(*Command).ExecuteC
	/Users/tassilo/go/pkg/mod/github.com/spf13/[email protected]/command.go:990
github.com/spf13/cobra.(*Command).Execute
	/Users/tassilo/go/pkg/mod/github.com/spf13/[email protected]/command.go:918
main.main
	/Users/tassilo/go/pkg/mod/github.com/volatiletech/sqlboiler/[email protected]/main.go:122
runtime.main
	/opt/homebrew/opt/go/libexec/src/runtime/proc.go:250
runtime.goexit
	/opt/homebrew/opt/go/libexec/src/runtime/asm_amd64.s:1598
unable to generate output
github.com/volatiletech/sqlboiler/v4/boilingcore.(*State).Run
	/Users/tassilo/go/pkg/mod/github.com/volatiletech/sqlboiler/[email protected]/boilingcore/boilingcore.go:198
main.run
	/Users/tassilo/go/pkg/mod/github.com/volatiletech/sqlboiler/[email protected]/main.go:260
github.com/spf13/cobra.(*Command).execute
	/Users/tassilo/go/pkg/mod/github.com/spf13/[email protected]/command.go:872
github.com/spf13/cobra.(*Command).ExecuteC
	/Users/tassilo/go/pkg/mod/github.com/spf13/[email protected]/command.go:990
github.com/spf13/cobra.(*Command).Execute
	/Users/tassilo/go/pkg/mod/github.com/spf13/[email protected]/command.go:918
main.main
	/Users/tassilo/go/pkg/mod/github.com/volatiletech/sqlboiler/[email protected]/main.go:122
runtime.main
	/opt/homebrew/opt/go/libexec/src/runtime/proc.go:250
runtime.goexit
	/opt/homebrew/opt/go/libexec/src/runtime/asm_amd64.s:1598

Please provide a relevant database schema so we can replicate your issue (Provided you are comfortable sharing this)

https://dbdesigner.page.link/BHmEiUykHqkEhWr99

Further information. What did you do, what did you expect?

Was trying to generate for the first time as described in the getting started guide.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions