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

Add a type escape hatch for columns #471

Open
Sandbagger opened this issue Nov 29, 2024 · 0 comments
Open

Add a type escape hatch for columns #471

Sandbagger opened this issue Nov 29, 2024 · 0 comments

Comments

@Sandbagger
Copy link

Sandbagger commented Nov 29, 2024

Is your feature request related to a problem? Please describe.
Ruby on Rails project supports a range of databases including SQLite. It uses DSL to manage database migrations so that you can write the migration once and expect it to work when you plug a different database in.

In the DSL for columns holding timestamps it sets the type to datetime. When I plug in a SQLite database the column type for timestamp columns is still recorded as datetime even though SQLite database only supports text (Rails does some magic with SQLite adapter to make a conversion behind the scenes).

sq inspect '@cp.users' -v
NAME   TYPE   ROWS  COLS  NAME        TYPE         PK
users  table  10    7     id          INTEGER      pk
                          first_name  varchar      
                          last_name   varchar      
                          email       varchar      
                          activated   boolean      
                          created_at  datetime(6)  
                          updated_at  datetime(6)  

When using sq and I try to read these sqlite 'timestamp' fields in these fields I get the following error:

sq: query against @cp: sql: Scan error on column index 5, name "created_at": unsupported Scan, storing driver.Value type string into type *time.Time

Describe the solution you'd like
This is really an issue with Rails implementation. However, it would be nice for me, but also maybe for others (but mainly me) if there was an escape hatch so that I could specify type for the column in an argument.

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

No branches or pull requests

1 participant