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

WIP: First attempt at roundtripping chrono types through SQLite #230

Closed
wants to merge 2 commits into from
Closed

Conversation

felipesere
Copy link
Contributor

@felipesere felipesere commented Apr 5, 2020

This is a first draft of what I believe needs to be done to store chono types into TIMESTAMP columns in SQLite.

My intent is to get a sense of direction with where I'm heading.
I am not 100% how to test this other than creating a bunch of databases and roundtripping a bunch of values.

Also, I am not sure if my decode is right?
I was expecting to work with affinity not with r#type()?

Any feedback is welcome ❤️

Addresses #164

@mehcode
Copy link
Member

mehcode commented Apr 7, 2020

This looks great. Good start. You'll want to add a few tests to sqlite-types. See postgres-types and the chrono section.

I was expecting to work with affinity not with r#type()?

SQLite has 3 classification systems for types.

  • Declared Type. This is the exact string a column is made with. CREATE TABLE FOO ( BAR BAZWHOWASIT ). The declared type is BAZWHOWASIT. We can let users use this system to inform the macros of the actual type. Like BOOLEAN or TIMESTAMP.

  • Type Affinity. When a declared type is encountered SQLite assigns an affinity from it of the 5 types. This is the "recommended type" for a column.

  • Data Type. Values themselves have a type when returned from the database. This does not have to be the same as the affinity.

For decoding we always want to work with the 3rd classification or "the actual type this data is".

@raftario
Copy link
Contributor

What's the status on this ? I'd be happy to rebase and do the remaining work to get this merged if you don't plan to do so @felipesere .

@mehcode
Copy link
Member

mehcode commented Jun 25, 2020

@raftario Please. I had talked to @felipesere and was planning to finish what was started here but I ( clearly, hah ) haven't gotten around to it.

Look to how BIGINT and BOOLEAN are supported for examples of non-standard-SQLite types.

@meteficha
Copy link
Contributor

I took a stab at this, and opened PR#458. I know @raftario mentioned he'd do this, but I kinda needed this now for one of my projects. I hope that's okay!

@mehcode
Copy link
Member

mehcode commented Jul 4, 2020

Thank you for starting this @felipesere. This is now in with the help of @meteficha !

@mehcode mehcode closed this Jul 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants