Skip to content

Conversation

@wesselvdv
Copy link
Contributor

resolves #660

I couldn't find any test(s) related to this portion of code?

@benjie
Copy link
Member

benjie commented Sep 18, 2020

Good catch! We mostly use integration tests, so please add a few columns to

create table b.types (
id serial primary key,
"smallint" smallint not null,
"bigint" bigint not null,
"numeric" numeric not null,
"decimal" decimal not null,
"boolean" boolean not null,
"varchar" varchar not null,
"enum" b.color not null,
"enum_array" b.color[] not null,
"domain" a.an_int not null,
"domain2" b.another_int not null,
"text_array" text[] not null,
"json" json not null,
"jsonb" jsonb not null,
"nullable_range" numrange,
"numrange" numrange not null,
"daterange" daterange not null,
"an_int_range" a.an_int_range not null,
"timestamp" timestamp not null,
"timestamptz" timestamptz not null,
"date" date not null,
"time" time not null,
"timetz" timetz not null,
"interval" interval not null,
"interval_array" interval[] not null,
"money" money not null,
"compound_type" c.compound_type not null,
"nested_compound_type" b.nested_compound_type not null,
"nullable_compound_type" c.compound_type,
"nullable_nested_compound_type" b.nested_compound_type,
"point" point not null,
"nullablePoint" point,
"inet" inet,
"cidr" cidr,
"macaddr" macaddr
);

Data to here:

And adjust the operations here:

https://github.com/graphile/graphile-engine/blob/v4/packages/postgraphile-core/__tests__/fixtures/queries/types.graphql

And here:

https://github.com/graphile/graphile-engine/blob/v4/packages/postgraphile-core/__tests__/fixtures/mutations/types.graphql

Then run

# To appease prettier
yarn lint:fix

# To run the tests and update the snapshots
cd packages/postgraphile-core
yarn test -u

And finally validate that these snapshot additions are what you'd expect.

@wesselvdv wesselvdv force-pushed the fix/primary-key-to-numeric-exceptions branch from 86525d2 to e8513ec Compare September 18, 2020 12:25
@wesselvdv
Copy link
Contributor Author

@benjie Thanks for the pointers. Also added the reg types to pgtypes plugin so they're not shown as BigFloat types.

@wesselvdv wesselvdv force-pushed the fix/primary-key-to-numeric-exceptions branch 3 times, most recently from a2d7345 to c3bd244 Compare September 18, 2020 13:27
@wesselvdv
Copy link
Contributor Author

I can't seem to easily support regrole and regnamespace without breaking support for pg 9.4

@benjie
Copy link
Member

benjie commented Sep 18, 2020

I can't seem to easily support regrole and regnamespace without breaking support for pg 9.4

Is that just for the tests, or functionality? If just tests, skip that for now (or add them to a pg10.* test)

@wesselvdv
Copy link
Contributor Author

I can't seem to easily support regrole and regnamespace without breaking support for pg 9.4

Is that just for the tests, or functionality? If just tests, skip that for now (or add them to a pg10.* test)

It's just for the tests, seeing that adding the oid type to the pgTypes plugin doesn't cause any breaking behaviour.

@wesselvdv wesselvdv force-pushed the fix/primary-key-to-numeric-exceptions branch from 69145c3 to cd31450 Compare September 22, 2020 08:51
@wesselvdv wesselvdv force-pushed the fix/primary-key-to-numeric-exceptions branch from cd31450 to ef3050e Compare September 22, 2020 09:04
@wesselvdv
Copy link
Contributor Author

@benjie Looks like I managed to get an all green on the tests. Let me know if something is not quite up to snuff, then I can always rework.

Copy link
Member

@benjie benjie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good 🙌

@benjie
Copy link
Member

benjie commented Sep 23, 2020

Please do not rebase or edit history from this point forward. I will squash and merge when the time comes.

@benjie
Copy link
Member

benjie commented Sep 28, 2020

@wesselvdv @-me when you're ready for a re-review. Though you've reset network_id_seq, the newly created pg10.types table still doesn't have the sequence reset for types_id_seq commented above.

@wesselvdv
Copy link
Contributor Author

@benjie I added the proper reset for types_id_seq and corrected the network_id_seq one.

Copy link
Member

@benjie benjie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there 🙌

@wesselvdv wesselvdv requested a review from benjie September 29, 2020 14:21
Copy link
Member

@benjie benjie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic 🙌 Thanks!

@benjie benjie changed the title fix(graphile-build-pg): add additional exceptions for casting to numeric fix(graphile-build-pg): add more numeric casting exceptions Sep 29, 2020
@benjie benjie merged commit ea8480e into graphile:v4 Sep 29, 2020
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

Successfully merging this pull request may close these issues.

bug(graphile-build-pg): using regclass as part of primary key results in cannot cast type regclass to numeric

2 participants