sqlc-dev / sqlc

Generate type-safe code from SQL
https://sqlc.dev
MIT License
13.52k stars 810 forks source link

public.vector doesn't emit pgvector.Vector #3548

Open newhook opened 3 months ago

newhook commented 3 months ago

Version

1.26.0

What happened?

My schema, generated from pg_dump, has:

embedding public.vector(1536)

This generates interface{} which won't scan correctly. Whereas

embedding vector(1536)

Generates pgvector.Vector which does.

Relevant log output

No response

Database schema

No response

SQL queries

No response

Configuration

No response

Playground URL

No response

What operating system are you using?

No response

What database engines are you using?

No response

What type of code are you generating?

No response

spa5k commented 2 months ago

Yeah, faced the same issue, change public.vector to vector works, also overriding it does not work in the sqlc

    gen:
      go:
        sql_package: "pgx/v5"
        out: "internal/database/models"
        package: "models"
        emit_db_tags: true
        emit_exported_queries: false
        emit_json_tags: true
        emit_prepared_queries: true
        emit_enum_valid_method: true
        emit_pointers_for_null_types: true
        emit_all_enum_values: true
        emit_sql_as_comment: true
        overrides:
          - db_type: "vector"
            go_type:
              import: "github.com/pgvector/pgvector-go"
              type: "pgvector.Vector"
              pointer: true