Comments (5)
I will test if the other CustomSqlTypes also work. I did see a closed issue where it says use the latest drift.
My packages are as follows:
drift 2.16.0
drift_postgres 1.2.0
postgres 3.1.2
uuid 4.3.3
from drift.
Using PgDate also gives an error:
this was the code used:
final result = await (srcDb.select(srcDb.posTrnTransactionHeader)
..where((tbl) => tbl.trnHdrStartDateTime
.equals(PgDateTime(DateTime.parse('2024-03-20')))))
.get();
SELECT * FROM pos_trn.transaction_header WHERE "trn_hdr_start_date_time" = $1; with args [2024-03-20 00:00:00.000]
package:drift_postgres/src/pg_database.dart 176:16 new _BoundArguments.ofDartArgs.<fn>
dart:core new _List.generate
package:drift_postgres/src/pg_database.dart 164:24 new _BoundArguments.ofDartArgs
package:drift_postgres/src/pg_database.dart 137:36 _PgDelegate.runSelect
package:drift/src/runtime/executor/helpers/engines.dart 77:19 _BaseExecutor.runSelect.<fn>
package:drift/src/runtime/executor/helpers/engines.dart 57:22 _BaseExecutor._synchronized.<fn>
dart:async new Future.sync
package:drift/src/utils/synchronized.dart 17:21 Lock.synchronized.callBlockAndComplete
package:drift/src/utils/synchronized.dart 23:14 Lock.synchronized
package:drift/src/runtime/executor/helpers/engines.dart 55:20 _BaseExecutor._synchronized
package:drift/src/runtime/executor/helpers/engines.dart 74:26 _BaseExecutor.runSelect
package:pepkor_db/src/base_postgres.dart 52:18 InterceptedPgDatabase.runSelect
package:drift/src/runtime/query_builder/statements/select/select.dart 81:16 SimpleSelectStatement._getRaw.<fn>
package:drift/src/runtime/api/connection_user.dart 162:64 DatabaseConnectionUser.doWhenOpened.<fn>
===== asynchronous gap ===========================
package:drift/src/runtime/query_builder/statements/select/select.dart 90:3 SimpleSelectStatement._mapResponse
===== asynchronous gap ===========================
test\database_tests\database_tests.dart 86:22 main.<fn>.<fn>
Invalid argument (value): Unsupported type: Instance of 'PgDateTime'
Process finished with exit code 1
from drift.
@simolus3 https://github.com/simolus3/drift/blob/develop/drift/lib/src/runtime/query_builder/helpers.dart#L58 The code here when building the expression goes to the default switch instead of assigning a customType.
I tested and checked if I replace the variable with
Variable(value, driftSqltypes.overrides[SqlDialect.postgres] as CustomSqlType<T>)
then the expression seems to correctly evaluate however I am not sure to get the GenerationContext so the Dialect can be mapped dynamically.
from drift.
This might have been fixed in e423157, which hasn't been released yet. Could you try using the current state from get to verify that it fixes the problem? You can add this to your pubspec to use it:
dependency_overrides:
drift:
git:
url: https://github.com/simolus3/drift.git
ref: develop
path: drift
from drift.
@simolus3 that worked, will close the issue thank you 👍
from drift.
Related Issues (20)
- Drift generator doesn't strip custom row class from SQL HOT 1
- Primary Key not required in companion insert HOT 2
- Issue with generated code: database.g.dart file HOT 29
- Select int64 return type HOT 4
- Start a select with the Dart API without specifiying a table HOT 4
- Custom query generated type missing nullables HOT 4
- [WEB] DriftRemoteException: RangeError (start): Invalid value: Not in inclusive range 0..2322399232: -1972640192 HOT 1
- createdAt & updatedAt columns HOT 4
- SqliteException(5): while selecting from statement, database is locked, database is locked (code 5) HOT 2
- drift files: file formatting impossible
- How to initialize the database without the constructor syntax HOT 2
- Add toJson() for result class HOT 1
- Query stream cancellations can affect migrations
- No modification allowed Error HOT 4
- Schema migration helper fails when there are no migrations yet HOT 1
- Views code generation HOT 7
- Cannot test migrations using modular approach with store_date_time_values_as_text: true HOT 4
- Unable to override `runs_before` in `build.yaml` due to `Unrecognized keys` exception HOT 2
- Support remote SQLite databases HOT 8
- drift_flutter package doesn't exist HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from drift.