Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upFollowing `diesel` sqlite example fails with 1.0.0-beta1 #1392
Comments
This comment has been minimized.
bitemyapp
commented
Dec 14, 2017
|
I've tried stable and nightly, same result. |
This comment has been minimized.
|
This is happening because you are running |
sgrif
closed this
Dec 14, 2017
This comment has been minimized.
bitemyapp
commented
Dec 14, 2017
|
No, I have migrations and I ran them. CREATE TABLE tweets (
id INTEGER PRIMARY KEY,
coordinates_x REAL,
coordinates_y REAL,
created_at INTEGER NOT NULL,
current_user_retweet INTEGER,
-- display_text_range_start
-- display_text_range_end
tweet_id INTEGER NOT NULL,
in_reply_to_status_id INTEGER,
text TEXT NOT NULL,
user TEXT
)Re-running
because I'd run them earlier. |
This comment has been minimized.
bitemyapp
commented
Dec 14, 2017
|
On a lark, I tried setting the
So I think it was looking in the wrong file location, pretty surprising to get this sort of error for that mistake. New error now is:
|
This comment has been minimized.
bitemyapp
commented
Dec 14, 2017
|
Schema in the sqlite3 database:
|
This comment has been minimized.
bitemyapp
commented
Dec 14, 2017
|
Fixed an erroneous (earlier) migration that included
|
This comment has been minimized.
bitemyapp
commented
Dec 14, 2017
|
Added recursion limit 128, then got:
|
This comment has been minimized.
bitemyapp
commented
Dec 14, 2017
|
After adding recursion limit 256 it seems like my problems are now narrowed down to |
This comment has been minimized.
|
@bitemyapp Did you figure out all your issues related to Diesel? The float problem doesn't seem like it's Diesel related. |
This comment has been minimized.
bitemyapp
commented
Dec 14, 2017
•
|
@sgrif almost: #[derive(Queryable)]
#[derive(Debug, Hash, PartialEq)]
pub struct DbTweet {
pub id: i32,
pub coordinates_x: Option<Double>,
pub coordinates_y: Option<Double>,
pub created_at: DateTime<Utc>,
pub current_user_retweet: Option<i32>,
pub tweet_id: i32,
pub in_reply_to_status_id: Option<i32>,
pub text: String,
pub user: Option<String>,
}
#[derive(Insertable)]
#[table_name="tweets"]
pub struct NewTweet {
pub coordinates_x: Option<Double>,
pub coordinates_y: Option<Double>,
pub created_at: DateTime<Utc>,
pub current_user_retweet: Option<i32>,
pub tweet_id: i32,
pub in_reply_to_status_id: Option<i32>,
pub text: String,
pub user: Option<String>,
}Results in the following errors:
This seems wrong. I'm trying to harmonize my model struct with the Then for a similar but different error:
Do I:
|
This comment has been minimized.
|
I'm not sure I understand what this has to do with chrono. If your column is |
This comment has been minimized.
bitemyapp
commented
Dec 14, 2017
•
|
I think I missed: https://docs.diesel.rs/diesel/types/struct.Timestamp.html but I suspect if I try to put that in my model type I'll run into the same problem I'm experiencing with the floating point type. Changing the types from
Edit: I tried
|
This comment has been minimized.
|
Can you please provide the code that is causing your problems, along with the full compiler output? Otherwise I can't do more beyond guess at what you're trying to do, or what's going wrong. If you want to use Glancing through our type mappings in SQLite, it looks like The error message " |
This comment has been minimized.
|
Also you can always see what types got inferred by using |
This comment has been minimized.
|
Ah, I see why we map |
This comment has been minimized.
bitemyapp
commented
Dec 14, 2017
|
I had to use I didn't say I was using f64 because of the docs, I said I was trying to use The last one appeared to be SQLite's somewhat unfortunate handling of dates requiring that I use |
This comment has been minimized.
bitemyapp
commented
Dec 14, 2017
|
For posterity's sake, here are the final models and migration (schema): #[derive(Queryable)]
#[derive(Debug, PartialEq)]
pub struct DbTweet {
pub id: i32,
pub coordinates_x: Option<f32>,
pub coordinates_y: Option<f32>,
pub created_at: i32,
pub current_user_retweet: Option<i32>,
pub tweet_id: i32,
pub in_reply_to_status_id: Option<i32>,
pub text: String,
pub user: Option<String>,
}
#[derive(Insertable)]
#[table_name="tweets"]
pub struct NewTweet {
pub coordinates_x: Option<f32>,
pub coordinates_y: Option<f32>,
pub created_at: i32,
pub current_user_retweet: Option<i32>,
pub tweet_id: i32,
pub in_reply_to_status_id: Option<i32>,
pub text: String,
pub user: Option<String>,
}CREATE TABLE tweets (
id INTEGER PRIMARY KEY,
coordinates_x REAL,
coordinates_y REAL,
created_at INTEGER NOT NULL,
current_user_retweet INTEGER,
-- display_text_range_start
-- display_text_range_end
tweet_id INTEGER NOT NULL,
in_reply_to_status_id INTEGER,
text TEXT NOT NULL,
user TEXT
) |
This comment has been minimized.
If you'd like to submit a PR that makes IDs unsigned on all the backends we support, I'd be happy to make that change. However, as it stands right now, they are signed.
We aren't restricting at all.
Can you be more specific about what you read that implied that you should do that? I'd like to improve the documentation to fix that error. The module for that type says (emphasis added):
SQLite does not have any requirement that you use |
This comment has been minimized.
bitemyapp
commented
Dec 14, 2017
OK
I mean, you can also use
My point is it's not a real date or timestamp column type.
I'm more exhausted now than I was when I was reading it. Maybe another time. |
This comment has been minimized.
Again, I'm not sure what you're getting at here. SQLite doesn't have a storage class for dates, but that doesn't affect our support for it.
Can you explain to me what you're looking for from a "real" date or timestamp column type that isn't provided? |
This comment has been minimized.
bitemyapp
commented
Dec 14, 2017
|
@sgrif not on your end, SQLite's. Alternative is newtyping and wrapping one of the supported representations. PostgreSQL has more completely supported date and datetime column types I double-checked, it turns out, only MySQL has real support for unsigned numbers, save for SQL Server's tinyint, so making the primary keys unsigned, while more faithful to how they get used in practice, is likely to cause some impedance. Unfortunate. I'm going to see how uniform the support for 64-bit numerics is meanwhile. Should be possible to do better than the ANSI spec. |
This comment has been minimized.
|
Just to be clear, you can call your column |
This comment has been minimized.
bitemyapp
commented
Dec 14, 2017
|
I'll leave it be and just assume something's missing on my end then. FWIW, when you say:
I have no earthly idea where you're proposing I put that text. But please don't tell me, put it in the docs if you're motivated. I'll keep-on with keeping-on with my thing rather than trying to fix the size for now. |
This comment has been minimized.
|
I'm referring to your database schema. e.g. the |
This comment has been minimized.
bitemyapp
commented
Dec 14, 2017
•
|
Your suggested column types don't neatly fit an The actual column type that maps unambiguously onto
|
This comment has been minimized.
I thought we were talking about
I think you may be confused about how SQLite's storage works. SQLite is dynamically typed. Any column can store a value of any type. "Storage classes" apply to values, not columns. Columns are given a "type affinity", which can sometimes affect which storage class is used, but only if that conversion is determined to be lossless. The only time storage classes are ever visible is if you are using
I've never said
The type affinity is virtually meaningless here. It only affects how storage occurs in cases where the conversion is lossless. You should never see any visible change in behavior due to type affinity of a column, and unless you are using
As I've mentioned, If you prefer to avoid |
This comment has been minimized.
|
This bit from the SQLite documentation may help clear things up:
|
This comment has been minimized.
bitemyapp
commented
Dec 14, 2017
I'm not confused at all. My point is that Instead, Diesel infers a type which cannot correctly or validly represent all possible values of an
I don't think this is steering in a direction that'll do anything useful, but thank you for taking the time so far. Have a good day! |
This comment has been minimized.
|
If you'd prefer to map to SQLite's type affinities, I recommend avoiding using |
bitemyapp commentedDec 14, 2017
•
edited
Expanded macro invocation error
The following should be a minimal repro from my
main.rs: