File tree Expand file tree Collapse file tree 4 files changed +50
-1
lines changed Expand file tree Collapse file tree 4 files changed +50
-1
lines changed Original file line number Diff line number Diff line change @@ -11,4 +11,21 @@ SQL.select().from('aircraft').where('tail_number').contains('N%').orderBy('model
11
11
1 . Exact knowledge of SQL syntax is unecessary, auto-competion will provide guidance
12
12
2 . No need to contruct cumbersome SQL strings
13
13
3 . Results in much clearner "pure-dart" code
14
- 4 . Does not require Flutter, can be used for CLI and Server applications of Dart
14
+ 4 . Does not require Flutter, can be used for CLI and Server applications of Dart
15
+
16
+ ## Examples
17
+
18
+ ``` dart
19
+ // SELECT * FROM aircraft
20
+ SQL.select().from('aircraft').toString();
21
+
22
+ // SELECT id, model, year FROM aircraft
23
+ SQL.select(['id', 'model', 'year']).from('aircraft').toString();
24
+
25
+ // INSERT INTO aircraft (model, year) VALUES ("SR22", "2014")
26
+ Map<String, dynamic> values = {"model": "SR22", "year": "2014"};
27
+ SQL.insert().into('aircraft').values(values).toString();
28
+
29
+ // DELETE FROM aircraft WHERE model = "SR22"'
30
+ SQL.delete().from('aircraft').where('model').eq("SR22").toString();
31
+ ```
Original file line number Diff line number Diff line change @@ -6,4 +6,11 @@ void main() {
6
6
7
7
// SELECT id, model, year FROM aircraft
8
8
SQL .select (['id' , 'model' , 'year' ]).from ('aircraft' ).toString ();
9
+
10
+ // INSERT INTO aircraft (model, year) VALUES ("SR22", "2014")
11
+ Map <String , dynamic > values = {"model" : "SR22" , "year" : "2014" };
12
+ SQL .insert ().into ('aircraft' ).values (values).toString ();
13
+
14
+ // DELETE FROM aircraft WHERE model = "SR22"'
15
+ SQL .delete ().from ('aircraft' ).where ('model' ).eq ("SR22" ).toString ();
9
16
}
Original file line number Diff line number Diff line change
1
+ import 'package:dart_sql/src/sql_writer.dart' ;
2
+
3
+ class SQLDefaultValues extends SQLWriter {
4
+ SQLDefaultValues (SQLWriter parent) : super (parent);
5
+
6
+ @override
7
+ void writeTo (StringSink sink) {
8
+ sink.write ('DEFAULT VALUES' );
9
+ }
10
+ }
Original file line number Diff line number Diff line change
1
+ import 'package:dart_sql/dart_sql.dart' ;
2
+ import 'package:dart_sql/src/sql_default_values.dart' ;
1
3
import 'package:dart_sql/src/sql_values.dart' ;
2
4
import 'package:dart_sql/src/sql_writer.dart' ;
3
5
@@ -6,12 +8,25 @@ class SQLInto extends SQLWriter {
6
8
7
9
String tableName;
8
10
11
+ String asName;
12
+
9
13
SQLValues values (Map <String , dynamic > values) {
10
14
return SQLValues (values: values, parent: this );
11
15
}
12
16
17
+ SQLSelectQuery select ([List <String > projection]) {
18
+ return SQLSelectQuery (projection: projection, parent: this );
19
+ }
20
+
21
+ SQLDefaultValues defaultValues () {
22
+ return SQLDefaultValues (this );
23
+ }
24
+
13
25
@override
14
26
void writeTo (StringSink sink) {
15
27
sink.write ('INTO $tableName ' );
28
+ if (asName != null ) {
29
+ sink.write ('AS $asName ' );
30
+ }
16
31
}
17
32
}
You can’t perform that action at this time.
0 commit comments