We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Insert
prepare()
The Rusqlite prepare() + execute() method need format like:
execute()
INSERT INTO \"virtual_file\" (\"path\", \"name\") VALUES (?, ?)
However, if we use Query::insert() without values_panic(), the build string look like this:
Query::insert()
values_panic()
INSERT INTO \"virtual_file\" (\"path\", \"name\") /* NO VALUE PART */
If we execute this prepared stmt, the DB return error
SqliteFailure(Error { code: Unknown, extended_code: 1 }, Some("incomplete input"))
We have to add empty values manually like this, It's unfriendly and confusing():
.values_panic(["".into(), "".into(), ...])
#[derive(Iden)] pub enum VirtualFile { Table, Id, Path, Name, } fn test_insert() { let conn = Connection::open("../sqlite.db").unwrap(); let sql = [Table::create() .table(VirtualFile::Table) .if_not_exists() .col( ColumnDef::new(VirtualFile::Id) .integer() .primary_key() .auto_increment(), ) .col(ColumnDef::new(VirtualFile::Path).string().not_null()) .col(ColumnDef::new(VirtualFile::Name).string().not_null()) .build(SqliteQueryBuilder)]; conn.execute_batch(&sql.join("; ")).unwrap(); let (sql, _) = Query::insert() .into_table(VirtualFile::Table) .columns([VirtualFile::Path, VirtualFile::Name]) //.values_panic(["".into(), "".into()]) // need to add this manually for insert stmt prepare .build(SqliteQueryBuilder); println!(">>> {:?}", &sql); let mut stmt = conn.prepare(&sql).unwrap(); stmt.execute(("path", "name")).unwrap(); }
When we use Query::insert() without values_panic(), the builder will generate VALUES (?, ?, ...) based on columns,
VALUES (?, ?, ...)
When we use Query::insert() without values_panic(), the builder generate
INSERT INTO \"virtual_file\" (\"path\", \"name\")
The text was updated successfully, but these errors were encountered:
Select
No branches or pull requests
Description
The Rusqlite
prepare()
+execute()
method need format like:However, if we use
Query::insert()
withoutvalues_panic()
, the build string look like this:If we execute this prepared stmt, the DB return error
SqliteFailure(Error { code: Unknown, extended_code: 1 }, Some("incomplete input"))
We have to add empty values manually like this, It's unfriendly and confusing():
Steps to Reproduce
Expected Behavior
When we use
Query::insert()
withoutvalues_panic()
, the builder will generateVALUES (?, ?, ...)
based on columns,Actual Behavior
When we use
Query::insert()
withoutvalues_panic()
, the builder generateReproduces How Often
Versions
The text was updated successfully, but these errors were encountered: