1245a196ce
We want to migrate the samples to NNBD. In order for the old samples to keep running on the legacy bots, this duplicates all samples, and changes the legacy bots to run the copies. Note this will cause the legacy bots to report that all the samples tests are skipped and that there are now new tests in the samples_2 suite. Existing failures may re-appear. These will be be re-approved or alternatively Skipped. The follow up CL migrates samples/ffi to NNBD. Issue: https://github.com/dart-lang/sdk/issues/43600. TEST=samples TEST=samples_2 Change-Id: Ib40f8fb71f81c091973aa0f860b1a49bac120d6c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/173523 Reviewed-by: Alexander Thomas <athom@google.com>
85 lines
2.2 KiB
Dart
85 lines
2.2 KiB
Dart
// 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.
|
|
|
|
// @dart = 2.9
|
|
|
|
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();
|
|
}
|