Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unable to get Cockroach ARRAY underlying type #18

Closed
pallavJha opened this issue Dec 3, 2018 · 8 comments
Closed

unable to get Cockroach ARRAY underlying type #18

pallavJha opened this issue Dec 3, 2018 · 8 comments

Comments

@pallavJha
Copy link

Error while model creation

$ cockroach version
Build Tag:    v2.1.1
Build Time:   2018/11/19 18:32:38
Distribution: CCL
Platform:     windows amd64 (x86_64-w64-mingw32)
Go Version:   go1.10.3
C Compiler:   gcc 6.3.0
Build SHA-1:  4523f9819d2dde9b054fc8faf1568e107f130986
Build Type:   release
$ go version
go version go1.11.1 windows/amd64

init.sql

CREATE TABLE scripts
(
  id                     UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  name                   string                   NOT NULL UNIQUE,
  content                string                   NOT NULL,
  type                   INT2                     NOT NULL,
  default_execution_time FLOAT                    NOT NULL,
  std_in                 STRING                   NOT NULL,
  status                 INT2                     NOT NULL,
  comments               STRING ARRAY             NOT NULL,
  created_at             TIMESTAMP WITH TIME ZONE NOT NULL,
  updated_at             TIMESTAMP WITH TIME ZONE NOT NULL,
  deleted_at             TIMESTAMP WITH TIME ZONE NULL,
  UNIQUE (name)
);

Error:

$ sqlboiler --wipe crdb --config=./configs/config.dev.toml
panic: unable to get Cockroach ARRAY underlying type [recovered]
        panic: interface conversion: string is not error: missing method Error

goroutine 1 [running]:
github.com/glerchundi/sqlboiler-crdb/driver.(*CockroachDBDriver).Assemble.func1(0xc000089c98, 0xc000089c90)
        C:/Users/PallavJha/code/pkg/mod/github.com/glerchundi/sqlboiler-crdb@v0.0.0-20181113123126-741c0b1e6ecc/driver/crdb.g
o:56 +0x78
panic(0x671c20, 0x712700)
        C:/Go/src/runtime/panic.go:513 +0x1c7
github.com/glerchundi/sqlboiler-crdb/driver.(*CockroachDBDriver).TranslateColumnType(0xc00005ca40, 0xc000066e90, 0x8, 0x0, 0x
0, 0xc000066ed5, 0x5, 0x0, 0x0, 0x0, ...)
        C:/Users/PallavJha/code/pkg/mod/github.com/glerchundi/sqlboiler-crdb@v0.0.0-20181113123126-741c0b1e6ecc/driver/crdb.g
o:484 +0x1df0
github.com/volatiletech/sqlboiler/drivers.Tables(0x715a80, 0xc00005ca40, 0x6c5cfe, 0x6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        C:/Users/PallavJha/code/pkg/mod/github.com/volatiletech/sqlboiler@v3.0.1+incompatible/drivers/interface.go:103 +0x309

github.com/glerchundi/sqlboiler-crdb/driver.(*CockroachDBDriver).Assemble(0xc00005ca40, 0xc0001083f0, 0x0, 0x0, 0x0)
        C:/Users/PallavJha/code/pkg/mod/github.com/glerchundi/sqlboiler-crdb@v0.0.0-20181113123126-741c0b1e6ecc/driver/crdb.g
o:97 +0x60e
github.com/volatiletech/sqlboiler/drivers.DriverMain(0x715340, 0xc00005ca40)
        C:/Users/PallavJha/code/pkg/mod/github.com/volatiletech/sqlboiler@v3.0.1+incompatible/drivers/driver_main.go:37 +0x30
c
main.main()
        C:/Users/PallavJha/code/pkg/mod/github.com/glerchundi/sqlboiler-crdb@v0.0.0-20181113123126-741c0b1e6ecc/main.go:9 +0x
44
Error: unable to initialize tables: unable to fetch table data: driver (C:\Users\PallavJha\code\bin\sqlboiler-crdb.exe) exite
d non-zero: exit status 2

encountered the same error after changing the DDL to

CREATE TABLE scripts
(
  id                     UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  name                   string                   NOT NULL UNIQUE,
  content                string                   NOT NULL,
  type                   INT2                     NOT NULL,
  default_execution_time FLOAT                    NOT NULL,
  std_in                 STRING                   NOT NULL,
  status                 INT2                     NOT NULL,
  comments               STRING[]                 NOT NULL,
  created_at             TIMESTAMP WITH TIME ZONE NOT NULL,
  updated_at             TIMESTAMP WITH TIME ZONE NOT NULL,
  deleted_at             TIMESTAMP WITH TIME ZONE NULL,
  UNIQUE (name)
);

BTW there weren't any errors when the DDL was:

CREATE TABLE scripts
(
  id                     UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  name                   string                   NOT NULL UNIQUE,
  content                string                   NOT NULL,
  type                   INT2                     NOT NULL,
  default_execution_time FLOAT                    NOT NULL,
  std_in                 STRING                   NOT NULL,
  status                 INT2                     NOT NULL,
  created_at             TIMESTAMP WITH TIME ZONE NOT NULL,
  updated_at             TIMESTAMP WITH TIME ZONE NOT NULL,
  deleted_at             TIMESTAMP WITH TIME ZONE NULL,
  UNIQUE (name)
);
@glerchundi
Copy link
Owner

Sorry for the radio silence, I'll take a look at this today and will tell you something.

@glerchundi
Copy link
Owner

Traced. This is related to this change: cockroachdb/cockroach#28945. In CockroachDB 2.1 data types were moved to information_schema.columns.crdb_sql_type column. Will try to fix as soon as possible.

Thanks for reporting.

@glerchundi
Copy link
Owner

@pallavJha I pushed a fix right now PTAL and reopen in case it doesn't make it for you.

glerchundi added a commit that referenced this issue Dec 13, 2018
@them0ntem
Copy link
Contributor

them0ntem commented Dec 13, 2018

@glerchundi, Facing this issue, after building a new binary from the master branch at commit (97aea0e)

Warning: Unhandled data type timestamptz, falling back to string
Warning: Unhandled data type timestamptz, falling back to string
Warning: Unhandled nullable data type timestamptz, falling back to null.String
Warning: Unhandled data type timestamptz, falling back to string
Warning: Unhandled data type timestamptz, falling back to string
Warning: Unhandled nullable data type timestamptz, falling back to null.String
Warning: Unhandled nullable data type timestamptz, falling back to null.String
Warning: Unhandled data type timestamptz, falling back to string
Warning: Unhandled data type timestamptz, falling back to string
Warning: Unhandled nullable data type timestamptz, falling back to null.String
Warning: Unhandled data type int2, falling back to string
Warning: Unhandled data type timestamptz, falling back to string
Warning: Unhandled data type timestamptz, falling back to string
Warning: Unhandled nullable data type timestamptz, falling back to null.String
Warning: Unhandled data type float8, falling back to string
Warning: Unhandled nullable data type int8, falling back to null.String
Warning: Unhandled data type float8, falling back to string
Warning: Unhandled nullable data type float8, falling back to null.String
Warning: Unhandled data type int2, falling back to string
Warning: Unhandled data type timestamptz, falling back to string
Warning: Unhandled data type timestamptz, falling back to string
Warning: Unhandled nullable data type timestamptz, falling back to null.String
Warning: Unhandled data type timestamptz, falling back to string
Warning: Unhandled data type timestamptz, falling back to string
Warning: Unhandled nullable data type timestamptz, falling back to null.String
Warning: Unhandled data type timestamptz, falling back to string
Warning: Unhandled data type timestamptz, falling back to string
Warning: Unhandled nullable data type timestamptz, falling back to null.String
Warning: Unhandled data type timestamptz, falling back to string
Warning: Unhandled data type timestamptz, falling back to string
Warning: Unhandled nullable data type timestamptz, falling back to null.String
Warning: Unhandled data type timestamptz, falling back to string
Warning: Unhandled data type timestamptz, falling back to string

Running test cases on newly generated models:

models\alerts.go:688:23: cannot use o.CreatedAt (type string) as type driver.Valuer in argument to queries.MustTime:
	string does not implement driver.Valuer (missing Value method)
models\alerts.go:689:22: cannot use &o.CreatedAt (type *string) as type sql.Scanner in argument to queries.SetScanner:
	*string does not implement sql.Scanner (missing Scan method)
models\alerts.go:691:23: cannot use o.UpdatedAt (type string) as type driver.Valuer in argument to queries.MustTime:
	string does not implement driver.Valuer (missing Value method)
models\alerts.go:692:22: cannot use &o.UpdatedAt (type *string) as type sql.Scanner in argument to queries.SetScanner:
	*string does not implement sql.Scanner (missing Scan method)
models\alerts.go:770:21: cannot use &o.UpdatedAt (type *string) as type sql.Scanner in argument to queries.SetScanner:
	*string does not implement sql.Scanner (missing Scan method)
models\alerts.go:904:23: cannot use o.CreatedAt (type string) as type driver.Valuer in argument to queries.MustTime:
	string does not implement driver.Valuer (missing Value method)
models\alerts.go:905:22: cannot use &o.CreatedAt (type *string) as type sql.Scanner in argument to queries.SetScanner:
	*string does not implement sql.Scanner (missing Scan method)
models\alerts.go:907:21: cannot use &o.UpdatedAt (type *string) as type sql.Scanner in argument to queries.SetScanner:
	*string does not implement sql.Scanner (missing Scan method)
models\audit_logs.go:374:23: cannot use o.CreatedAt (type string) as type driver.Valuer in argument to queries.MustTime:
	string does not implement driver.Valuer (missing Value method)
models\audit_logs.go:375:22: cannot use &o.CreatedAt (type *string) as type sql.Scanner in argument to queries.SetScanner:
	*string does not implement sql.Scanner (missing Scan method)
models\audit_logs.go:375:22: too many errors

@glerchundi
Copy link
Owner

Test with latest, pushed another fix concretely for this data type.

@them0ntem
Copy link
Contributor

them0ntem commented Dec 13, 2018

Warning: Unhandled data type int2, falling back to string
Warning: Unhandled data type float8, falling back to string
Warning: Unhandled nullable data type int8, falling back to null.String
Warning: Unhandled data type float8, falling back to string
Warning: Unhandled nullable data type float8, falling back to null.String
Warning: Unhandled data type int2, falling back to string
Warning: Unhandled data type int2, falling back to string
Warning: Unhandled data type float8, falling back to string
Warning: Unhandled data type int2, falling back to string

Also need to fix data type for int2, float8.

@glerchundi
Copy link
Owner

PTAL to latest @themontem.

@them0ntem
Copy link
Contributor

Awesome, working fine now. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants