Giter Site home page Giter Site logo

Comments (6)

griffio avatar griffio commented on July 22, 2024

Can confirm - it's specifically using the VALUES ? special SqlDelight syntax

It should work withINSERT INTO "order" (id) VALUES (?);

from sqldelight.

frevib avatar frevib commented on July 22, 2024

@griffio thx, that will work for now.

But then you would have to call saveOrder with many parameterssaveOrder(id, a, b, c, ...) instead of just saveOrder(order).

I wouldn't mind fixing this bug myself, but it's not trivial to get into Sqldelight with all its lexing, parsing, PSI etc. Are there some docs to learn how the code works?

from sqldelight.

griffio avatar griffio commented on July 22, 2024

@frevib issue has come up before #4877 and is not specific to Postgresql Dialect

For fixing bugs, only some basic overview is given here https://github.com/cashapp/sqldelight/blob/6fa1522ca3e87b8e1379891a7d30422489198753/CONTRIBUTING.md - sadly it requires lots of trial and error to implement somethings.

An entry point to investigating issues is to start by adding a test that can be debugged here

e.g Add a test to allow debugging

  @Test fun `issue 5298`() {
    val file = FixtureCompiler.compileSql(
      """
      |CREATE TABLE "order" (
      |  data_id INTEGER NOT NULL
      |);
      |selectForId:
      |INSERT INTO "order" VALUES ?;
      """.trimMargin(),
      tempFolder,
      overrideDialect = PostgreSqlDialect()
    )

    val column = file.compiledFile
    println(column)
  }

🎯 Place your debugger in some places:

You can see the difference if you use INSERT INTO "order" (data_id) VALUES (?) vs INSERT INTO "order" VALUES ? the table name from the sq file is being replaced with order

Have a look and see if you want to take a try at it?

from sqldelight.

griffio avatar griffio commented on July 22, 2024

Another issue is that sometimes the problem is located in the SqlPsi project

e.g This problem could be here ??? -> https://github.com/AlecKazakova/sql-psi/blob/9d51d00e622afe3cc06c722f9cf8181b89b8dd30/core/src/main/kotlin/com/alecstrong/sql/psi/core/psi/SqlNamedElementImpl.kt#L25

The table name is being trimmed from ""order"" to "order"

TreeUtil is using the sqlpsi SqlNamedElementImpl

🔨 One potential quick fix is to use tableName.node.text instead of using the text accessor
e.g prefix = "${parent!!.tableName.node.text} to get the unmodified table name

from sqldelight.

frevib avatar frevib commented on July 22, 2024

Earlier I was looking at:

but the replacements seems to contain (?) most of the time when debugging the unit tests.

For SELECT queries the generated code is correct, so we could have look why that flow is producing correct results.

I will have a look and see how far I can come with this issue.

from sqldelight.

frevib avatar frevib commented on July 22, 2024

fix #5303

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.