-
-
Notifications
You must be signed in to change notification settings - Fork 35
Support for SQLite Datatypes #12
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
Conversation
Current coverage is 69.49% (diff: 74.32%)@@ master #12 diff @@
==========================================
Files 3 5 +2
Lines 156 177 +21
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
+ Hits 104 123 +19
- Misses 52 54 +2
Partials 0 0
|
|
I like the changes here a lot, but I think we should use the This makes it easier to implement the Fluent driver as well as making for a much more robust API for those using this package by itself. |
|
Okay ! you're right, Node provides better integration with Vapor and allows writing more legible code. |
|
Looks great! I think we will need to tag this as 2.0.0, though, since the public API will change. This shouldn't be too much of an issue because we can just upgrade the |
|
Oh sure ! sqlite-driver would update to something like 1.1, or 2.0 as well ? |
|
We're probably going to need to tag the driver as 2.0 as well or else it could cause dependency hell for other packages that use 1.*. I'm going to integrate the new fluent test suite here first in case I need to clean anything up there. Then I will update and tag. |
Support for SQLite Datatypes
Author :
Introduction
This PR aims at making SQLite datatypes available to the Fluent's SQLite driver through an enum supporting all available types in SQLite. Plus since a few lines of code were added, I separated the code in 4 files.
[EDIT] The enum has been changed to Node for better integration with Fluent.
Motivation
I don't know if this PR should be considered an enhancement or a fix. SQLite currently gets a
Stringfrom a row instead of its real type. When converted to a node, it is converted toNode.stringeven though the data was inserted as anIntor aDouble.It raised a serious issue when wanting to create a
Pivotwith aModelfetched from a database.In fact, the id was saved as a
Node.stringwhich made it impossible for fluent to retrieve other objects with this id.Proposed solution
I suggest creating an enum called
SQLite.DataTypethat would represent the four possible SQLite types retrievable which are : Integer, Floating number, String and Null.In my opinion, it wouldn't be relevant to create a node directly since it's already the driver's job with its
mapfunction.[EDIT] See intro
Code Snippet
Impact
The impact would be pretty much inexistant. The one I can think of is from developers who would have fixed this issue by casting their custom properties in their model.
Alternative considered ++
Instead of creating a new type, It would be possible to convert to a Node directly but it would require SQLite to import Node which might not be relevant since it is a very powerful feature for such a small C wrapper. Plus, SQLite driver for Fluent already does that.