mirror of https://github.com/AMT-Cheif/drift.git
Add table-valued query to test moor file
This commit is contained in:
parent
71ef9b8cd7
commit
27430cbb07
|
@ -1181,11 +1181,18 @@ abstract class _$CustomTablesDb extends GeneratedDatabase {
|
|||
readsFrom: {config}).map(_rowToConfig);
|
||||
}
|
||||
|
||||
Selectable<Config> findValidJsons() {
|
||||
TableValuedResult _rowToTableValuedResult(QueryRow row) {
|
||||
return TableValuedResult(
|
||||
key: row.readString('key'),
|
||||
value: row.readString('value'),
|
||||
);
|
||||
}
|
||||
|
||||
Selectable<TableValuedResult> tableValued() {
|
||||
return customSelectQuery(
|
||||
'SELECT * FROM config WHERE json_valid(config_value)',
|
||||
'SELECT\n "key", "value"\n FROM config, json_each(config.config_value)\n WHERE json_valid(config_value)',
|
||||
variables: [],
|
||||
readsFrom: {config}).map(_rowToConfig);
|
||||
readsFrom: {config}).map(_rowToTableValuedResult);
|
||||
}
|
||||
|
||||
MultipleResult _rowToMultipleResult(QueryRow row) {
|
||||
|
@ -1270,6 +1277,23 @@ abstract class _$CustomTablesDb extends GeneratedDatabase {
|
|||
];
|
||||
}
|
||||
|
||||
class TableValuedResult {
|
||||
final String key;
|
||||
final String value;
|
||||
TableValuedResult({
|
||||
this.key,
|
||||
this.value,
|
||||
});
|
||||
@override
|
||||
int get hashCode => $mrjf($mrjc(key.hashCode, value.hashCode));
|
||||
@override
|
||||
bool operator ==(dynamic other) =>
|
||||
identical(this, other) ||
|
||||
(other is TableValuedResult &&
|
||||
other.key == this.key &&
|
||||
other.value == this.value);
|
||||
}
|
||||
|
||||
class MultipleResult {
|
||||
final String a;
|
||||
final int b;
|
||||
|
|
|
@ -41,7 +41,11 @@ END;
|
|||
readConfig: SELECT * FROM config WHERE config_key = ?;
|
||||
readMultiple: SELECT * FROM config WHERE config_key IN ? ORDER BY $clause;
|
||||
readDynamic: SELECT * FROM config WHERE $predicate;
|
||||
findValidJsons: SELECT * FROM config WHERE json_valid(config_value);
|
||||
|
||||
tableValued:
|
||||
SELECT "key", "value"
|
||||
FROM config, json_each(config.config_value)
|
||||
WHERE json_valid(config_value);
|
||||
|
||||
@create: INSERT INTO config (config_key, config_value) VALUES ('key', 'values');
|
||||
|
||||
|
|
|
@ -339,7 +339,12 @@ mixin ExpressionParser on ParserBase {
|
|||
}
|
||||
}
|
||||
|
||||
_error('Could not parse this expression');
|
||||
if (_peek is KeywordToken) {
|
||||
_error('Could not parse this expressions. Note: This is a reserved '
|
||||
'keyword, you can escape it in double ticks');
|
||||
} else {
|
||||
_error('Could not parse this expression');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
Loading…
Reference in New Issue