-
Notifications
You must be signed in to change notification settings - Fork 6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[vm/ffi] Add copyright headers to sqlite example and incorporate Mich…
…ael's feedback. Change-Id: I83555a81bb6394a8c2a740a5127175be85aabf3d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98007 Commit-Queue: Samir Jindel <sjindel@google.com> Reviewed-by: Michael Thomsen <mit@google.com> Auto-Submit: Samir Jindel <sjindel@google.com>
- Loading branch information
1 parent
7a15b02
commit 991c9da
Showing
12 changed files
with
126 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
import "package:test/test.dart"; | ||
|
||
import "../lib/sqlite.dart"; | ||
|
||
void main() { | ||
Database d = Database("test.db"); | ||
d.execute("drop table if exists Cookies;"); | ||
d.execute(""" | ||
create table Cookies ( | ||
id integer primary key, | ||
name text not null, | ||
alternative_name text | ||
);"""); | ||
d.execute(""" | ||
insert into Cookies (id, name, alternative_name) | ||
values | ||
(1,'Chocolade chip cookie', 'Chocolade cookie'), | ||
(2,'Ginger cookie', null), | ||
(3,'Cinnamon roll', null) | ||
;"""); | ||
Result result = d.query(""" | ||
select | ||
id, | ||
name, | ||
alternative_name, | ||
case | ||
when id=1 then 'foo' | ||
when id=2 then 42 | ||
when id=3 then null | ||
end as multi_typed_column | ||
from Cookies | ||
;"""); | ||
for (Row r in result) { | ||
int id = r.readColumnAsInt("id"); | ||
String name = r.readColumnByIndex(1); | ||
String alternativeName = r.readColumn("alternative_name"); | ||
dynamic multiTypedValue = r.readColumn("multi_typed_column"); | ||
print("$id $name $alternativeName $multiTypedValue"); | ||
} | ||
result = d.query(""" | ||
select | ||
id, | ||
name, | ||
alternative_name, | ||
case | ||
when id=1 then 'foo' | ||
when id=2 then 42 | ||
when id=3 then null | ||
end as multi_typed_column | ||
from Cookies | ||
;"""); | ||
for (Row r in result) { | ||
int id = r.readColumnAsInt("id"); | ||
String name = r.readColumnByIndex(1); | ||
String alternativeName = r.readColumn("alternative_name"); | ||
dynamic multiTypedValue = r.readColumn("multi_typed_column"); | ||
print("$id $name $alternativeName $multiTypedValue"); | ||
if (id == 2) { | ||
result.close(); | ||
break; | ||
} | ||
} | ||
try { | ||
result.iterator.moveNext(); | ||
} on SQLiteException catch (e) { | ||
print("expected exception on accessing result data after close: $e"); | ||
} | ||
try { | ||
d.query(""" | ||
select | ||
id, | ||
non_existing_column | ||
from Cookies | ||
;"""); | ||
} on SQLiteException catch (e) { | ||
print("expected this query to fail: $e"); | ||
} | ||
d.execute("drop table Cookies;"); | ||
d.close(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
samples/ffi/sqlite/lib/src/collections/closable_iterator.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters