Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit 3366bda

Browse files
committed
fix(postgres): replace ArgumentError with InvalidInputException in query builder
1 parent 8799f34 commit 3366bda

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

lib/src/ht_data_postgres.dart

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -176,19 +176,13 @@ class HtDataPostgresClient<T> implements HtDataClient<T> {
176176
try {
177177
// Note: startAfterId is not yet implemented for PostgreSQL client.
178178
// Keyset pagination would be required for a robust implementation.
179-
final (String, Map<String, dynamic>) queryParts;
180-
try {
181-
queryParts = _queryBuilder.buildSelect(
182-
query: query,
183-
userId: userId,
184-
limit: limit,
185-
sortBy: sortBy,
186-
sortOrder: sortOrder,
187-
);
188-
} on ArgumentError catch (e) {
189-
throw InvalidInputException(e.message);
190-
}
191-
final (sql, params) = queryParts;
179+
final (sql, params) = _queryBuilder.buildSelect(
180+
query: query,
181+
userId: userId,
182+
limit: limit,
183+
sortBy: sortBy,
184+
sortOrder: sortOrder,
185+
);
192186

193187
final result = await connection.execute(
194188
Sql.named(sql),
@@ -394,7 +388,7 @@ class _QueryBuilder {
394388
// This prevents basic injection by only allowing alphanumeric, underscore,
395389
// and dot characters, then replacing dots.
396390
if (!RegExp(r'^[a-zA-Z0-9_.]+$').hasMatch(name)) {
397-
throw ArgumentError('Invalid column name format: $name');
391+
throw InvalidInputException('Invalid column name format: $name');
398392
}
399393
return name.replaceAll('.', '_');
400394
}

0 commit comments

Comments
 (0)