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

[Postgres] schema command fails: error: sql: Scan error on column index 1, name "enumsortorder" #344

Open
mikestefanello opened this issue Feb 2, 2022 · 5 comments

Comments

@mikestefanello
Copy link

Trying to generate a schema with xo for the first time.

$ mkdir -p models
$ xo schema "pgsql://postgres@localhost:5432/dev?sslmode=disable"

error: sql: Scan error on column index 1, name "enumsortorder": converting driver.Value type float64 ("34.5") to a int: invalid syntax
@hhhapz
Copy link
Contributor

hhhapz commented Feb 3, 2022

Hey, thanks for submitting an issue! It's really hard to help debug the problem when we dont have access to the schema :(. If you share more information including a way to reproduce the error, it makes it easier for us to help

@mikestefanello
Copy link
Author

I understand. I was hoping to first see if the error made it clear what in the schema would be causing this. I unfortunately cannot share the schema entirely. We're debugging this and will report back with more info. It seems there's a problem with an enum using a non-int value and an index with a conversion.

@mikestefanello
Copy link
Author

I can confirm that's the source of this problem - an enum with a non-int value (in this case, it is 34.5).

The other error, which I can open a separate issue for if you'd like, is error: could not find public.table_name index index_name column id 0. It has a conversion on it, ie lower(name).

@mikestefanello
Copy link
Author

I created a new issue for the second problem: #345

@mikestefanello
Copy link
Author

This was the result of a migration that added a value before another.

IE:

ALTER TYPE t_my_type
    ADD VALUE 'NEW_VALUE' BEFORE 'EXISTING_VALUE';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants