preparedExecute not populating row names like query
jdalberg opened this issue · comments
Jesper Dalberg commented
I was using preparedExecute in my code, and was confused when i took a look at the row items returned from queries, so i wrote a new testcase for it in integration/row.dart
So mine now looks like this...
part of integrationtests;
void runRowTests(String user, String password, String db, int port, String host) {
ConnectionPool pool;
group('row tests:', () {
test('setup', () {
pool = new ConnectionPool(user:user, password:password, db:db, port:port, host:host, max:1);
return setup(pool, "row", "create table row (id integer, name text, "
"`the field` text, length integer)");
});
test('store data', () {
var c = new Completer();
pool.prepare('insert into row (id, name, `the field`, length) values (?, ?, ?, ?)').then((query) {
query.execute([0, 'Bob', 'Thing', 5000]).then((Results results) {
c.complete();
});
});
return c.future;
});
test('select from stream using query and listen', () {
var futures = [];
for (var i = 0; i < 5; i++) {
var c = new Completer();
pool.query('select * from row').then((Results results) {
results.listen((row) {
expect(row.id, equals(0));
expect(row.name.toString(), equals("Bob"));
// length is a getter on List, so it isn't mapped to the result field
expect(row.length, equals(4));
}, onDone: () {
c.complete();
});
});
futures.add(c.future);
}
return Future.wait(futures);
});
test('select from stream using prepareExecute and listen', () {
var futures = [];
for (var i = 0; i < 5; i++) {
var c = new Completer();
pool.prepareExecute('select * from row where id = ?',[0]).then((Results results) {
results.listen((row) {
expect(row.id, equals(0));
expect(row.name.toString(), equals("Bob"));
// length is a getter on List, so it isn't mapped to the result field
expect(row.length, equals(4));
}, onDone: () {
c.complete();
});
});
futures.add(c.future);
}
return Future.wait(futures);
});
test('close connection', () {
pool.close();
});
});
}
Am I right in assuming that this should pass?
It fails
Class '_BinaryDataPacket' has no instance getter 'id'.
James Ots commented
Yes, it should pass. It looks like I forgot to add 'get by name' functionality to prepared query results. I will fix this.