Open BlobCodes opened 5 years ago
Hey, @BlobCodes,
You see, there is really no SQL standard to join array references. SQLite doesn't support arrays at all, and PG, in contrary, has more than one way to do it. I'm planning on removing the ability to join array refs in an upcoming release to make Onyx::SQL more SQL.
However, IIRC PG join should work in this case, looks like the query generated by it is flawed. I'll take a deeper look into it.
Don't forget that you can do Onyx::SQL.query(User, "SELECT * FROM users ..."))
as a workaround. Onyx::SQL would never be a replacement for SQL itself. Its query builder is just a helper. It's better to rely on raw SQL in complex cases. Also remember that Query(T).build
would output an SQL string which you can them modify as you want.
I'm trying to query a
User
and itsgroups
. This generates an invalid SQL Query:..resulting in runtime errors. This is a minimal representation of what I'm trying to do (and how you can reproduce the error):
This results in the following errors: SQLite3 Error:
PG error:
Here is a SQLite3 DB to test it: test.db.zip
Just install the shards sqlite3 and onyx-sql and run
DATABASE_URL="sqlite3://./test.db" crystal src/test.cr
to test it yourself.