Giter Site home page Giter Site logo

Comments (3)

griffio avatar griffio commented on September 25, 2024 2

๐Ÿ‘ป Looks like missing the type from SqlBinaryExpr

SMALL_INT,
PostgreSqlType.INTEGER,
INTEGER,
BIG_INT,
REAL,
TEXT,
BLOB,
PostgreSqlType.INTERVAL,
PostgreSqlType.TIMESTAMP_TIMEZONE,
PostgreSqlType.TIMESTAMP,
PostgreSqlType.JSON,
PostgreSqlType.TSVECTOR,

Can be fixed by adding UUID and probably some more missing types but needs to have table interface tests

from sqldelight.

griffio avatar griffio commented on September 25, 2024

The only thing I would add is that the query above has a syntax error with the comma, that is not valid SQL so not sure how it ran -syntax error at or near "FROM"

Do you have other examples that show a compilation error?

someQuery:
SELECT some_table_1.id AS id,
       some_table_2.id IS NOT NULL AS check_table_2,
       some_table_3.id IS NOT NULL AS check_table_3,
       some_table_4.id IS NOT NULL AS check_table_4, <-- Comma here is not valid in SQL 
FROM some_table_1
LEFT JOIN some_table_2 ON some_table_2.id = some_table_1.id
LEFT JOIN some_table_3 ON some_table_3.id = some_table_1.id
LEFT JOIN some_table_4 ON some_table_4.id = some_table_1.id
WHERE some_table_1.id = :id;

from sqldelight.

lnhrdt avatar lnhrdt commented on September 25, 2024

Good catch. I hastily obfuscated my domain from the example and made a couple mistakes in the process. Here's a new example that I've tested demonstrates the issue:

Tables

CREATE TABLE companyRecord (
  id UUID PRIMARY KEY,
  name TEXT NOT NULL
);

CREATE TABLE companyAttributes (
  id UUID PRIMARY KEY REFERENCES companyRecord,
  slogan TEXT NOT NULL
);

Queries

testQuery1:
SELECT companyRecord.id,
       companyRecord.name,
       companyAttributes.slogan IS NOT NULL AS has_slogan
FROM companyRecord
LEFT JOIN companyAttributes ON companyAttributes.id = companyRecord.id
WHERE companyRecord.id = ?;

testQuery2:
SELECT companyRecord.id,
       companyRecord.name,
       companyAttributes.id IS NOT NULL AS has_attributes
FROM companyRecord
LEFT JOIN companyAttributes ON companyAttributes.id = companyRecord.id
WHERE companyRecord.id = ?;

testQuery1 compiles fine. testQuery2 fails to compile with this error:

> A failure occurred while executing app.cash.sqldelight.gradle.SqlDelightTask$GenerateInterfaces
   > Failed to compile PostgreSqlCompoundSelectStmtImpl(COMPOUND_SELECT_STMT): [] :
     SELECT companyRecord.id,
            companyRecord.name,
            companyAttributes.id IS NOT NULL AS has_attributes
     FROM companyRecord
     LEFT JOIN companyAttributes ON companyAttributes.id = companyRecord.id
     WHERE companyRecord.id = ?

The error is not surfaced in IntelliJ through the SQLDelight pluginโ€“it is only shown through compilation.

from sqldelight.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.