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

zod validation (fixes #364) #367

Closed
wants to merge 5 commits into from
Closed

zod validation (fixes #364) #367

wants to merge 5 commits into from

Conversation

gajus
Copy link
Owner

@gajus gajus commented Aug 4, 2022

No description provided.

@gajus gajus temporarily deployed to release August 4, 2022 03:34 Inactive
@gajus gajus temporarily deployed to release August 4, 2022 03:34 Inactive
Copy link
Contributor

@mmkal mmkal left a comment

Choose a reason for hiding this comment

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

Pretty scared by the deletion of the type tests. I wrote most of them for very specific use cases that my team/I have in production in multiple projects. Very likely many others have the same requirements. Is slonik no longer supporting those use cases?

test/types.ts Outdated Show resolved Hide resolved

const anyTypedQuery = await client.any(sql<Row>``);
expectTypeOf(anyTypedQuery).toEqualTypeOf<readonly Row[]>();
const anyTyped = await client.any(sql.type(Row)``);
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think the old test should be deleted? Is slonik going to stop supporting sql<Row>`select 123`?? I would have thought this is just a new feature and should have corresponding new type tests. Right now this PR deletes many many tests that ensure slonik's types are correct for end users (since test/dts.ts also got deleted entirely).

Copy link
Owner Author

Choose a reason for hiding this comment

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

I don't see a path for supporting both. They don't mix will.

What happens if someone does:

sql<{id: number}>.type(
    z.object({
      id: z.string()
    })
)`select 123`

Copy link
Contributor

Choose a reason for hiding this comment

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

Not a risk - that isn't valid ts syntax. The generic on sql is only when used as a function directly. sql.type is another, independent, generic function which returns a non-generic function. I'm very sure of this, and still pretty concerned about abandoning the existing (and totally satisfactory!) form slonik has now. If you're not convinced, can I have a few days to come up with a pull request which proves this out?

Copy link
Owner Author

Choose a reason for hiding this comment

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

If you're not convinced, can I have a few days to come up with a pull request which proves this out?

Absolutely!

@mmkal mmkal mentioned this pull request Aug 4, 2022
@gajus gajus temporarily deployed to release August 4, 2022 13:13 Inactive
@gajus gajus temporarily deployed to release August 4, 2022 13:13 Inactive
@gajus gajus temporarily deployed to release August 4, 2022 13:13 Inactive
@gajus gajus temporarily deployed to release August 4, 2022 13:13 Inactive
@gajus gajus temporarily deployed to release August 4, 2022 13:18 Inactive
@gajus gajus temporarily deployed to release August 4, 2022 13:18 Inactive
@gajus gajus temporarily deployed to release August 4, 2022 13:18 Inactive
@gajus gajus temporarily deployed to release August 4, 2022 13:18 Inactive
@gajus gajus temporarily deployed to release August 4, 2022 13:18 Inactive
@gajus gajus temporarily deployed to release August 4, 2022 13:18 Inactive
@gajus gajus temporarily deployed to release August 4, 2022 13:19 Inactive
@gajus gajus temporarily deployed to release August 4, 2022 13:19 Inactive
@gajus gajus temporarily deployed to release August 4, 2022 13:32 Inactive
@gajus gajus temporarily deployed to release August 4, 2022 13:32 Inactive
@gajus gajus temporarily deployed to release August 4, 2022 13:32 Inactive
@gajus gajus temporarily deployed to release August 4, 2022 13:32 Inactive
@gajus gajus temporarily deployed to release August 4, 2022 14:03 Inactive
@gajus gajus temporarily deployed to release August 4, 2022 14:03 Inactive
@gajus gajus temporarily deployed to release August 4, 2022 14:03 Inactive
@gajus gajus temporarily deployed to release August 4, 2022 14:03 Inactive
@gajus gajus temporarily deployed to release August 4, 2022 14:13 Inactive
@gajus gajus temporarily deployed to release August 4, 2022 14:13 Inactive
@gajus gajus temporarily deployed to release August 4, 2022 14:13 Inactive
@gajus gajus temporarily deployed to release August 4, 2022 14:13 Inactive
@gajus gajus mentioned this pull request Aug 4, 2022
@gajus
Copy link
Owner Author

gajus commented Aug 5, 2022

Closing in favor of #369.

@gajus gajus closed this Aug 5, 2022
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.

None yet

2 participants