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

Upcoming special SQL NULL handling in drift_postgres #2947

Open
davidmartos96 opened this issue Apr 10, 2024 · 2 comments
Open

Upcoming special SQL NULL handling in drift_postgres #2947

davidmartos96 opened this issue Apr 10, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@davidmartos96
Copy link
Contributor

Hello!
This is just to open a discussion on how would be the best way to support the upcoming SQL NULL values in the postgres package.

Particularly via the Dart select API and the customSelect method.

Originally the use case for json null was discovered when we were doing some polishing on the ElectricSQL Dart type mapping between Postgres and the drift schema. There were some issues with how the types were being mapped in your PR. Now the tests are run on a real Postgres instance so it's easier to see what's behaving differently.

Context: isoos/postgresql-dart#322

@davidmartos96 davidmartos96 added the enhancement New feature or request label Apr 10, 2024
@simolus3
Copy link
Owner

When binding parameters, you can always write a custom type mapping to a TypedValue and drift won't mess with that, it's passed to the postgres package unchanged. That's probably what you would be doing for JSON/JSONB either way, right? So just setting the relevant flag to not turn that into an SQL null is sufficient.

The other direction is more complicated unfortunately, as we don't have access to the ResultRow in higher layers of drift, only the interpreted map. Do you need a way to distinguish the nulls in this direction as well?

@davidmartos96
Copy link
Contributor Author

Yes, I was able to do the inserts with TypedValue via drift.
For the rows reading we could actually use the CustomType API if that's a possible solution. But right now, nulls don't go through it. This would be the ideal solution as we already have control over how the values are mapped in/out for all the supported types.

I agree it is a niche case. We don't have an use case other than being able to work with Electric supported values transparently via drift on the backend, same as on the client, which supports the JSON null on SQLite by using a custom serialization/deserialization.

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

No branches or pull requests

2 participants