mirror of https://github.com/AMT-Cheif/drift.git
Escape column names in updates
This commit is contained in:
parent
348fb655ce
commit
79294e248a
|
@ -1,3 +1,7 @@
|
|||
## 3.0.2
|
||||
|
||||
- Fix update statements not escaping column names ([#539](https://github.com/simolus3/moor/issues/539))
|
||||
|
||||
## 3.0.1
|
||||
|
||||
- Fix `mapFromRowOrNull` not working without a prefix ([#534](https://github.com/simolus3/moor/pull/534))
|
||||
|
|
|
@ -23,7 +23,7 @@ class UpdateStatement<T extends Table, D extends DataClass> extends Query<T, D>
|
|||
first = false;
|
||||
}
|
||||
|
||||
ctx.buffer..write(columnName)..write(' = ');
|
||||
ctx.buffer..write(escapeIfNeeded(columnName))..write(' = ');
|
||||
|
||||
variable.writeInto(ctx);
|
||||
});
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
name: moor
|
||||
description: Moor is a safe and reactive persistence library for Dart applications
|
||||
version: 3.0.1
|
||||
version: 3.0.2
|
||||
repository: https://github.com/simolus3/moor
|
||||
homepage: https://moor.simonbinder.eu/
|
||||
issue_tracker: https://github.com/simolus3/moor/issues
|
||||
|
|
|
@ -52,7 +52,7 @@ void main() {
|
|||
'INSERT INTO todos (content) VALUES (?)',
|
||||
'UPDATE users SET name = ?;',
|
||||
'UPDATE users SET name = ? WHERE name = ?;',
|
||||
'UPDATE categories SET desc = ? WHERE id = ?;',
|
||||
'UPDATE categories SET `desc` = ? WHERE id = ?;',
|
||||
'DELETE FROM categories WHERE 1;',
|
||||
'DELETE FROM todos WHERE id = ?;',
|
||||
],
|
||||
|
|
|
@ -54,6 +54,15 @@ void main() {
|
|||
[1, 3],
|
||||
));
|
||||
});
|
||||
|
||||
test('with escaped column names', () async {
|
||||
await db
|
||||
.update(db.pureDefaults)
|
||||
.write(const PureDefaultsCompanion(txt: Value('foo')));
|
||||
|
||||
verify(executor
|
||||
.runUpdate('UPDATE pure_defaults SET `insert` = ?;', ['foo']));
|
||||
});
|
||||
});
|
||||
|
||||
group('generates replace statements', () {
|
||||
|
|
Loading…
Reference in New Issue