Skip to content

Commit

Permalink
Adjustments to pass dartfmt checks
Browse files Browse the repository at this point in the history
  • Loading branch information
bobjackman committed Apr 18, 2019
1 parent 3dc7af8 commit da57c5b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
7 changes: 5 additions & 2 deletions lib/src/prepared_statements/binary_data_packet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@ import '../results/row.dart';
class BinaryDataPacket extends Row {
final Logger log = new Logger("BinaryDataPacket");

BinaryDataPacket.forTests(List _values) { values = _values; }
BinaryDataPacket.forTests(List _values) {
values = _values;
}

BinaryDataPacket(Buffer buffer, List<Field> fieldPackets) {
buffer.skip(1);
var nulls = buffer.readList(((fieldPackets.length + 7 + 2) / 8).floor().toInt());
var nulls =
buffer.readList(((fieldPackets.length + 7 + 2) / 8).floor().toInt());
log.fine("Nulls: $nulls");
var nullMap = new List<bool>(fieldPackets.length);
var shift = 2;
Expand Down
21 changes: 12 additions & 9 deletions lib/src/query/standard_data_packet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,38 +39,39 @@ class StandardDataPacket extends Row {
return null;
}

Object value;
switch (field.type) {
case FIELD_TYPE_TINY: // tinyint/bool
case FIELD_TYPE_SHORT: // smallint
case FIELD_TYPE_INT24: // mediumint
case FIELD_TYPE_LONGLONG: // bigint/serial
case FIELD_TYPE_LONG: // int
var s = utf8.decode(list);
return int.parse(s);
value = int.parse(s);
break;
case FIELD_TYPE_NEWDECIMAL: // decimal
case FIELD_TYPE_FLOAT: // float
case FIELD_TYPE_DOUBLE: // double
var s = utf8.decode(list);
return double.parse(s);
value = double.parse(s);
break;
case FIELD_TYPE_BIT: // bit
var value = 0;
for (var num in list) {
value = (value << 8) + num;
}
return value;
value = value;
break;
case FIELD_TYPE_DATE: // date
case FIELD_TYPE_DATETIME: // datetime
case FIELD_TYPE_TIMESTAMP: // timestamp
var s = utf8.decode(list);
return DateTime.parse(s).toUtc();
value = DateTime.parse(s).toUtc();
break;
case FIELD_TYPE_TIME: // time
var s = utf8.decode(list);
var parts = s.split(":");
return new Duration(
value = new Duration(
days: 0,
hours: int.parse(parts[0]),
minutes: int.parse(parts[1]),
Expand All @@ -79,21 +80,23 @@ class StandardDataPacket extends Row {
break;
case FIELD_TYPE_YEAR: // year
var s = utf8.decode(list);
return int.parse(s);
value = int.parse(s);
break;
case FIELD_TYPE_STRING: // char/binary/enum/set
case FIELD_TYPE_VAR_STRING: // varchar/varbinary
var s = utf8.decode(list);
return s;
value = s;
break;
case FIELD_TYPE_BLOB: // tinytext/text/mediumtext/longtext/tinyblob/mediumblob/blob/longblob
return new Blob.fromBytes(list);
value = new Blob.fromBytes(list);
break;
case FIELD_TYPE_GEOMETRY: // geometry
var s = utf8.decode(list);
return s;
value = s;
break;
}

return value;
}

String toString() => "Fields: $fields";
Expand Down
3 changes: 2 additions & 1 deletion test/integration/one_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,8 @@ void main() {
expect(v2, equals(v1));

// Binary packet
results = await conn.query('select atinyint from test1 WHERE ? = ?', [1, 1]);
results =
await conn.query('select atinyint from test1 WHERE ? = ?', [1, 1]);
int v3 = results.first.fields['atinyint'];
int v4 = results.first['atinyint'];
expect(v3, isNotNull);
Expand Down

0 comments on commit da57c5b

Please sign in to comment.