You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ColumnSerializable implementation is incomplete #1591
/// A [Column] holding an [SerializableEntity]. The entity will be stored in the/// database as a json column.classColumnSerializableextendsColumn<String> {
/// Creates a new [Column], this is typically done in generated code only.ColumnSerializable(super.columnName, super.table);
// TODO: Add comparisons and possibly other operations
}
At a minimum, this needs to support isNotNull() or similar, so that List<T>? types can be checked for nullness.
is there any work for it?
I have a table that defines vouchers for users and I want to create report that how many vouchers a user used. if a user use voucher code I just want to add users id to usersIdsAlreadyUsed column. then when I want to see statics for the user I want to list vouchers used by user by checking usersIdsAlreadyUsed column.
I now try to use this function for this purpose but Im not sure if its safe and good practice to use
Future<List<Voucher>> getVouchersByUser(Session session,int userId) async {
// ? Eğer kullanıcı bunu bir sefer kullandıysa tekrar kullanamaz.
DatabaseResult result = await session.db.unsafeQuery(
r'SELECT * FROM vouchers WHERE usersIdsAlreadyUsed @> $1::int[]',
parameters: QueryParameters.positional([
[userId],
]),
);
return result.toList().map((e) => Voucher.fromJson(e.toColumnMap())).toList();
}
If you give me a reference link I believe I also can add some features for ColumnSerializable class.
How's progress of this going, when can we get this?
@iampopal There is no current work being done on this. We are restoring the work on JSONB support, which will be important for column operations on stored objects. Once JSONB is in, we're open to receive contributions for this feature.
So the issue is that ColumnSerializable in columns.dart still has that TODO the maintainers left about comparisons not being finished, and lukehutch called out the actual gap you can't check nullness on a nullable list column like List?. Basically I can't write a query that says "give me rows where this list column isn't null."
My plan: go find wherever the existing comparison operators live on that class Serverpod's query columns pretty much mirror SQL operators (equals, notEquals, etc.), each one building an Expression under the hood and add an isNotNull() that follows the same pattern, just emitting IS NOT NULL. Rough shape of what it'd probably look like:
dart
Expression isNotNull() {
return Expression('$queryAlias.$columnName IS NOT NULL');
}
Before I actually touch anything I'm going to pull the repo, open columns.dart, and see how isNull() or any other comparator is written, then copy that structure exactly so it doesn't look bolted on. I'll add a test next to the existing column tests too. There are already two PRs linked on the issue (#5656, #5354) — gonna check those first so I'm not duplicating someone else's work.
Activity
SandPod commentedon Nov 22, 2023
You are correct, the implementation for ColumnSerializable does not yet support any column operations.
This needs to be implemented 👍
lukehutch commentedon Feb 4, 2024
Yes, nothing has changed
SandPod commentedon Feb 12, 2024
@al-ik Yes, this is still free and open for taking.
xyzbilal commentedon Aug 17, 2024
is there any work for it?
I have a table that defines vouchers for users and I want to create report that how many vouchers a user used. if a user use voucher code I just want to add users id to usersIdsAlreadyUsed column. then when I want to see statics for the user I want to list vouchers used by user by checking usersIdsAlreadyUsed column.
I now try to use this function for this purpose but Im not sure if its safe and good practice to use
If you give me a reference link I believe I also can add some features for ColumnSerializable class.
Thanks.
binemmanuel commentedon Oct 25, 2024
I despise the fact that I have to write an SQL query for this and serialise the data myself, resulting in this much latency 🤦🏾♂️🤦🏾♂️
METHOD CALL: errand.getAll duration: 116ms numQueries: 0 authenticatedUser: 21Thanks to caching, I'm able to reduce latency
METHOD CALL: errand.getAll duration: 7ms numQueries: 0 authenticatedUser: 21iampopal commentedon Jul 14, 2025
I need this too. looking for it.
iampopal commentedon Aug 5, 2025
Looking for a solution for this...
iampopal commentedon Apr 15, 2026
How's progress of this going, when can we get this?
marcelomendoncasoares commentedon Apr 15, 2026
@iampopal There is no current work being done on this. We are restoring the work on JSONB support, which will be important for column operations on stored objects. Once JSONB is in, we're open to receive contributions for this feature.
enesbugrahankilic commentedon Aug 31, 2026
Opening a PR to add null-comparison operations to ColumnSerializable.
fix: add null comparison ops to ColumnSerializable
fix: add null comparison ops to ColumnSerializable
rajput-abdullah commentedon Sep 1, 2026
So the issue is that ColumnSerializable in columns.dart still has that TODO the maintainers left about comparisons not being finished, and lukehutch called out the actual gap you can't check nullness on a nullable list column like List?. Basically I can't write a query that says "give me rows where this list column isn't null."
My plan: go find wherever the existing comparison operators live on that class Serverpod's query columns pretty much mirror SQL operators (equals, notEquals, etc.), each one building an Expression under the hood and add an isNotNull() that follows the same pattern, just emitting IS NOT NULL. Rough shape of what it'd probably look like:
dart
Expression isNotNull() {
return Expression('$queryAlias.$columnName IS NOT NULL');
}
Before I actually touch anything I'm going to pull the repo, open columns.dart, and see how isNull() or any other comparator is written, then copy that structure exactly so it doesn't look bolted on. I'll add a test next to the existing column tests too. There are already two PRs linked on the issue (#5656, #5354) — gonna check those first so I'm not duplicating someone else's work.