Comments (10)
having a different runtime could also allow proper wrapping for the TIMESTAMP types correct ?
i assume the postgres driver exposes function to send and retrieve those without the need to blindly throw strings at the server.. i hope
and i bet there is more PG specific data types i just did not try to use yet
from sql-psi.
Another related datatype could be UUID
. Postgres supports uuids as a first class type, but currently sql-psi binds them as a string type. #289 This is awkward when querying, as UUIDs returned from a query will be a String, but using UUID as a query parameters requires a manual cast to VARCHAR
. I'm unsure of the query performance impact this has.
It looks like pgsql's implementation of JDBC ResultSet
allows getting UUID's natively. Looks like it also supports getting Date objects as well.
from sql-psi.
This is very similar to the issue with SERIAL
(#150), where BOOLEAN
has been added to sql-psi (#141), but the plumbing in SQLDelight hasn't been done to get this type to work. I'll try and get a fix out within the next couple of days.
from sql-psi.
@AlecStrong It looks like we finally reached the limits of tunneling the PostgreSQL types into SQLite types by way of IntermediateType.SqliteType
, as I'd want to access ResultSet#getBoolean(Int)
to support this change, but SqliteJdbcCursor
doesn't support it.
This looks like it could be a big change (e.g., introducing PostgreSqlJdbcCursor
, reassessing the API of IntermediateType
). Before I go ham on refactoring, I'm interested in what API design choices you have in mind, considering you've thought about this much more than I have (#155).
from sql-psi.
able to push a branch? interested in playing around with it for a bit.
i think what this will probably result in is separate runtimes as well likeruntime-postgres
which extends SqlCursor
to have a getBoolean()
or whatever function.
from sql-psi.
is it okay to call getInt()
on that column? would it return 0/1? If thats the case you should be able to do the same thing we do for MySQL's boolean type: https://github.com/cashapp/sqldelight/blob/master/sqldelight-compiler/src/main/kotlin/com/squareup/sqldelight/core/lang/psi/sqlTypeName.kt#L41
that will use getInt() == 1
and so the kotlin side will be a boolean. If calling getInt()
on the column throws (because it only works with getBoolean()
) then yea we'll have to iterate on the runtime API
from sql-psi.
In MySQL, BOOLEAN
is just a synonym for TINYINT(1)
, so it's just a glorified integer. In PostgreSQL, BOOLEAN
is its own separate type, and to retrieve it as 0 or 1 it'd need to be casted to an integer.
I verified this behavior by doing what you said, and added the following case to this when
expression:
booleanDataType != null -> IntermediateType(IntermediateType.SqliteType.INTEGER, BOOLEAN)
And changed the dog
table in dog.sq
to:
CREATE TABLE dog (
name VARCHAR(8) NOT NULL,
breed TEXT NOT NULL,
is_good BOOLEAN NOT NULL
);
Running the integration tests results in the following exception as expected:
org.postgresql.util.PSQLException: ERROR: column "is_good" is of type boolean but expression is of type bigint
Hint: You will need to rewrite or cast the expression.
Position: 33
at …
from sql-psi.
Literally just a two line change, but here ya go: https://github.com/veyndan/sqldelight/tree/sql-psi-156/boolean
from sql-psi.
yea I would expect the timestamp stuff is also going to have the same problem
from sql-psi.
fixed on sqldelight master
from sql-psi.
Related Issues (20)
- No snapshots published
- Retrieving day of week value from date HOT 1
- Support the Information Schema
- Fix 2022.2 compability HOT 2
- Using 0.5.0-SNAPSHOT with Sqldelight fails with migrations referencing tables from other files HOT 1
- [Postgres] network address types inet cidr macaddr
- Duplicate class failure with Timber HOT 3
- HAVING Statement does not compile without GROUP BY
- Test fixture failure prevents override of Mixin HOT 1
- Support create type statement in core grammer
- Test fixtures aren't not valid ansi sql
- Delete statements with a limit throws a compiler error HOT 1
- CTEs auxiliary insert with select statements cannot reference each other HOT 1
- Sqlite and PostreSql - INSERT INTO ... SELECT ... RETURNING * fails to compile
- Checking if list is null leads to compile error
- False positive Multiple columns found with name coachTagId
- Add info about which signing keys will be used for published artifacts.
- Insert Statement exposes its columns in the SELECT query
- No sql-psi core 0.4.10
- Improve tableAlias and qualified column resolving
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sql-psi.