| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | |||
| 8 | 8 | ||
| 9 | 9 | ## [0.1.6] - 2018-11-30 | |
| 10 | 10 | ### Added | |
| 11 | + - `SQLiteCursor#getBool()` method | ||
| 11 | 12 | ||
| 12 | 13 | ## [0.1.5] - 2018-11-30 | |
| 13 | 14 | ### Added | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -129,7 +129,7 @@ Reference | |||
| 129 | 129 | - [`SQLiteDatabase#beginTransactionNonExclusive()`](https://pub.dartlang.org/documentation/flutter_sqlcipher/latest/sqlite/SQLiteDatabase/beginTransactionNonExclusive.html) | |
| 130 | 130 | - [`SQLiteDatabase#endTransaction()`](https://pub.dartlang.org/documentation/flutter_sqlcipher/latest/sqlite/SQLiteDatabase/endTransaction.html) | |
| 131 | 131 | - [`SQLiteDatabase#execSQL()`](https://pub.dartlang.org/documentation/flutter_sqlcipher/latest/sqlite/SQLiteDatabase/execSQL.html) | |
| 132 | - - [`SQLiteDatabase#getAttachedDbs`](https://pub.dartlang.org/documentation/flutter_sqlcipher/latest/sqlite/SQLiteDatabase/getAttachedDbs.html) | ||
| 132 | + - [`SQLiteDatabase#getAttachedDbs()`](https://pub.dartlang.org/documentation/flutter_sqlcipher/latest/sqlite/SQLiteDatabase/getAttachedDbs.html) | ||
| 133 | 133 | - [`SQLiteDatabase#getMaximumSize()`](https://pub.dartlang.org/documentation/flutter_sqlcipher/latest/sqlite/SQLiteDatabase/getMaximumSize.html) | |
| 134 | 134 | - [`SQLiteDatabase#getPageSize()`](https://pub.dartlang.org/documentation/flutter_sqlcipher/latest/sqlite/SQLiteDatabase/getPageSize.html) | |
| 135 | 135 | - [`SQLiteDatabase#getPath()`](https://pub.dartlang.org/documentation/flutter_sqlcipher/latest/sqlite/SQLiteDatabase/getPath.html) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -22,17 +22,33 @@ class SQLiteCursor extends MatrixCursor { | |||
| 22 | 22 | SQLiteCursor.from({@required List<String> columns, @required List<List<dynamic>> rows}) | |
| 23 | 23 | : super.from(columns: columns, rows: rows); | |
| 24 | 24 | ||
| 25 | + /// Returns the value of the requested column as a boolean. | ||
| 26 | + /// | ||
| 27 | + /// See: https://www.sqlite.org/datatype3.html#boolean_datatype | ||
| 28 | + bool getBool(final int columnIndex) { | ||
| 29 | + switch (getType(columnIndex)) { | ||
| 30 | + case Cursor.FIELD_TYPE_NULL: | ||
| 31 | + return null; | ||
| 32 | + case Cursor.FIELD_TYPE_INTEGER: | ||
| 33 | + return getInt(columnIndex) != 0; | ||
| 34 | + default: | ||
| 35 | + throw SQLiteDatatypeMismatchException(); | ||
| 36 | + } | ||
| 37 | + } | ||
| 38 | + | ||
| 25 | 39 | /// Returns the value of the requested column as a UTC instant in time. | |
| 26 | 40 | /// | |
| 27 | - /// See: https://www.sqlite.org/lang_datefunc.html | ||
| 41 | + /// See: https://www.sqlite.org/datatype3.html#date_and_time_datatype | ||
| 28 | 42 | DateTime getDateTime(final int columnIndex) { | |
| 29 | 43 | switch (getType(columnIndex)) { | |
| 30 | 44 | case Cursor.FIELD_TYPE_NULL: | |
| 31 | 45 | return null; | |
| 32 | - case Cursor.FIELD_TYPE_INTEGER: | ||
| 33 | - return DateTime.fromMillisecondsSinceEpoch(getInt(columnIndex), isUtc: true); | ||
| 34 | - case Cursor.FIELD_TYPE_STRING: | ||
| 46 | + case Cursor.FIELD_TYPE_STRING: // ISO-8601 strings ("YYYY-MM-DD HH:MM:SS.SSS") | ||
| 35 | 47 | return DateTime.parse(getString(columnIndex)); // TODO: default timezone? | |
| 48 | + case Cursor.FIELD_TYPE_INTEGER: // Unix time, seconds since 1970-01-01T00:00:00Z | ||
| 49 | + return DateTime.fromMillisecondsSinceEpoch(getInt(columnIndex) * 1000, isUtc: true); | ||
| 50 | + case Cursor.FIELD_TYPE_FLOAT: // Julian day numbers | ||
| 51 | + // TODO: implement support for Julian day numbers; for now, fall through: | ||
| 36 | 52 | default: | |
| 37 | 53 | throw SQLiteDatatypeMismatchException(); | |
| 38 | 54 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments