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

Temp table created using schema.sql is not insertable. #3345

Open
adi-kmt opened this issue Apr 18, 2024 · 3 comments
Open

Temp table created using schema.sql is not insertable. #3345

adi-kmt opened this issue Apr 18, 2024 · 3 comments
Labels
bug Something isn't working triage New issues that hasn't been reviewed

Comments

@adi-kmt
Copy link

adi-kmt commented Apr 18, 2024

Version

1.26.0

What happened?

Even though the table seems to be created, its not able to insert into that table saying that the schema 'table' is not found.

Relevant log output

schema not found

Database schema

No response

SQL queries

CREATE TEMP TABLE temp_table (LIKE prev_table include ALL) ON COMMIT DROP;
INSERT INTO temp_table (...) VALUES (...)

Configuration

version: "2"
sql:
  - engine: "postgresql"
    queries: "db/query/"
    schema: "db/migrations/"
    gen:
      go:
        package: "db"
        sql_package: "pgx/v5"
        out: "db/sqlc"
        emit_interface: true
        emit_json_tags: true
        emit_pointers_for_null_types: true
        emit_result_struct_pointers: true
        overrides:

Playground URL

No response

What operating system are you using?

Linux

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

@adi-kmt adi-kmt added bug Something isn't working triage New issues that hasn't been reviewed labels Apr 18, 2024
@adi-kmt
Copy link
Author

adi-kmt commented Apr 18, 2024

@Jille created the issue here. Even removing the ON COMMIT DROP doesn't seem to work. How to put it in the same session?
I'm using the conn.Begin() to start the transaction.

@Jille
Copy link
Contributor

Jille commented Apr 18, 2024

If you're using a transaction you're in the same session by definition.

Can you share your code? Which call gives that error exactly?

@adi-kmt
Copy link
Author

adi-kmt commented Apr 19, 2024

Using sqlc generate itself is causing the error. Should the create temp table command not be in the same file as the rest of the sql query commands?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage New issues that hasn't been reviewed
Projects
None yet
Development

No branches or pull requests

2 participants