diff --git a/packages/postgrest/lib/src/postgrest_rpc.dart b/packages/postgrest/lib/src/postgrest_rpc.dart index bcc406191..7420b98d6 100644 --- a/packages/postgrest/lib/src/postgrest_rpc.dart +++ b/packages/postgrest/lib/src/postgrest_rpc.dart @@ -79,14 +79,23 @@ final class PostgrestRpc { /// arguments, or the value of a function's sole unnamed `json` or `jsonb` /// parameter. The call addresses [schema] unless this object was scoped /// with [PostgrestClient.schema]. + /// + /// When [get] is set, the function is called with a `GET` request in + /// read-only access mode, so that it is retried like a select. + /// [arguments] are then sent as query parameters, so they have to be a + /// [Map] of values a query parameter can hold, and not rows or `json`. A + /// call with an argument PostgREST would read as an option of the request, + /// such as `limit`, a `null` value, or a value it would read as a filter, + /// such as `eq.foo`, is sent as a `POST` instead and not retried. @experimental PostgrestTypedFilterBuilder> rows( String function, { Object? arguments, required RowConverter rowFromJson, String? schema, + bool get = false, }) => PostgrestTypedFilterBuilder._( - _request(function, arguments, rowFromJson, schema), + _request(function, arguments, rowFromJson, schema, get), PostgrestHttpTableExecutor(_client), (result) => [ for (final row in result.data! as List) @@ -105,19 +114,21 @@ final class PostgrestRpc { /// ); /// ``` /// - /// See [rows] for [arguments] and [schema]. + /// See [rows] for [arguments], [schema] and [get]. @experimental PostgrestTypedBuilder value( String function, { Object? arguments, required T Function(Object? json) fromJson, String? schema, + bool get = false, }) => PostgrestTypedBuilder._( _request( function, arguments, _noRows, schema, + get, ).copyWith(shape: PostgrestResultShape.value), PostgrestHttpTableExecutor(_client), (result) => fromJson(result.data), @@ -128,16 +139,27 @@ final class PostgrestRpc { Object? arguments, RowConverter rowFromJson, String? schema, - ) => PostgrestTableRequest( - table: PostgrestTable( - function, - rowFromJson, - primaryKey: const [], - ), - operation: PostgrestTableOperation.rpc, - schema: _schemaIsExplicit ? _schema : (schema ?? _schema), - payload: arguments, - ); + bool get, + ) { + if (get && arguments is! Map?) { + throw ArgumentError.value( + arguments, + 'arguments', + 'A call with get set takes a map of named arguments', + ); + } + return PostgrestTableRequest( + table: PostgrestTable( + function, + rowFromJson, + primaryKey: const [], + ), + operation: PostgrestTableOperation.rpc, + schema: _schemaIsExplicit ? _schema : (schema ?? _schema), + payload: arguments, + readOnly: get, + ); + } } Never _noRows(Map json) => diff --git a/packages/postgrest/lib/src/postgrest_table_executor.dart b/packages/postgrest/lib/src/postgrest_table_executor.dart index 7af7779fd..f9919a1ec 100644 --- a/packages/postgrest/lib/src/postgrest_table_executor.dart +++ b/packages/postgrest/lib/src/postgrest_table_executor.dart @@ -137,12 +137,16 @@ final class PostgrestHttpTableExecutor implements PostgrestTableExecutor { /// The function call of [request], decoding a response read as rows into /// a [PostgrestList] the way a select does. /// - /// A HEAD request has no body, so a call read with - /// [PostgrestResultShape.head] sends its arguments as query parameters. + /// A GET or HEAD request has no body, so a [PostgrestTableRequest.readOnly] + /// call, and a call read with [PostgrestResultShape.head], sends its + /// arguments as query parameters. A read-only call whose arguments + /// PostgREST would read as filters is sent as a POST instead. PostgrestFilterBuilder _call(PostgrestTableRequest request) { final name = request.table.name; - final head = request.shape == PostgrestResultShape.head; - final arguments = head + final get = + request.shape == PostgrestResultShape.head || + (request.readOnly && _fitsQueryParameters(request.payload)); + final arguments = get ? (request.payload ?? const {}) : request.payload; if (request.shape == PostgrestResultShape.value) { @@ -151,6 +155,7 @@ final class PostgrestHttpTableExecutor implements PostgrestTableExecutor { name, request.schema, params: arguments, + get: get, ); } // ignore: invalid_use_of_internal_member @@ -158,10 +163,42 @@ final class PostgrestHttpTableExecutor implements PostgrestTableExecutor { name, request.schema, params: arguments, - get: head, + get: get, ); } + /// Whether PostgREST passes every one of [arguments] to the function when + /// they are sent as query parameters. It does not when a name is an option + /// of the request, `limit`, or an embed path, when a value is `null`, which + /// a query parameter can only carry as the text `null`, or when a value + /// starts like a filter, `eq.foo` or `not.in.(1)`, which it applies to the + /// result instead. + static bool _fitsQueryParameters(Object? arguments) => + arguments is! Map || + arguments.entries.every( + (argument) => + !_reservedQueryParameters.contains(argument.key) && + !'${argument.key}'.contains('.') && + argument.value != null && + !_filterSyntax.hasMatch(renderPostgrestQueryValue(argument.value)), + ); + + static const _reservedQueryParameters = { + 'select', + 'columns', + 'on_conflict', + 'order', + 'limit', + 'offset', + 'and', + 'or', + }; + + static final _filterSyntax = RegExp( + r'^(not\.)?(eq|gte?|lte?|neq|i?like|i?match|cs|cd|ov|sl|sr|nx[lr]|adj|' + r'in|is|isdistinct|(pl|ph|w)?fts)(\([^)]*\))?\.', + ); + static void _rejectFilter( PostgrestFilter? filter, PostgrestTableOperation operation, diff --git a/packages/postgrest/lib/src/postgrest_table_request.dart b/packages/postgrest/lib/src/postgrest_table_request.dart index 2a51675c6..39c84fe69 100644 --- a/packages/postgrest/lib/src/postgrest_table_request.dart +++ b/packages/postgrest/lib/src/postgrest_table_request.dart @@ -177,6 +177,7 @@ final class PostgrestTableRequest { this.shape = PostgrestResultShape.rows, this.countOption, this.payload, + this.readOnly = false, List>? onConflict, this.ignoreDuplicates = false, this.defaultToNull = true, @@ -243,6 +244,14 @@ final class PostgrestTableRequest { /// later, an outbox for example, serializes the payload when it takes it. final Object? payload; + /// Whether a [PostgrestTableOperation.rpc] call only reads, so that it can + /// run in a read-only transaction and be retried like a select. + /// + /// [PostgrestHttpTableExecutor] sends such a call as a `GET`, with + /// [payload] as query parameters, unless PostgREST would read one of them + /// as an option of the request or as a filter. + final bool readOnly; + /// The columns of the unique constraint an upsert merges on, or `null` for /// the primary key. final List>? onConflict; @@ -292,6 +301,7 @@ final class PostgrestTableRequest { PostgrestResultShape? shape, CountOption? countOption, Object? payload, + bool? readOnly, List>? onConflict, bool? ignoreDuplicates, bool? defaultToNull, @@ -314,6 +324,7 @@ final class PostgrestTableRequest { shape: shape ?? this.shape, countOption: countOption ?? this.countOption, payload: payload ?? this.payload, + readOnly: readOnly ?? this.readOnly, onConflict: onConflict ?? this.onConflict, ignoreDuplicates: ignoreDuplicates ?? this.ignoreDuplicates, defaultToNull: defaultToNull ?? this.defaultToNull, diff --git a/packages/postgrest/test/typed_rpc_integration_test.dart b/packages/postgrest/test/typed_rpc_integration_test.dart index f3880360a..f2d3f2858 100644 --- a/packages/postgrest/test/typed_rpc_integration_test.dart +++ b/packages/postgrest/test/typed_rpc_integration_test.dart @@ -94,6 +94,41 @@ void main() { await postgrest.rpc.value('void_func', fromJson: (json) {}); }); + test('calls a function read-only with its arguments in the query', () async { + final rows = await postgrest.rpc + .rows( + 'get_username_and_status', + arguments: {'name_param': 'supabot'}, + rowFromJson: UserStatus.new, + get: true, + ) + .where(UserStatuses.status.eq('ONLINE')); + expect(rows.single.username, 'supabot'); + + final element = await postgrest.rpc.value( + 'get_array_element', + arguments: { + 'arr': [37, 420, 64], + 'index': 2, + }, + fromJson: (json) => json as int?, + get: true, + ); + expect(element, 420); + }); + + test('calls a function read-only with an argument that looks like a ' + 'filter', () async { + final status = await postgrest.rpc.value( + 'get_status', + arguments: {'name_param': 'eq.supabot'}, + fromJson: (json) => json as String?, + get: true, + ); + + expect(status, isNull); + }); + test('calls a function of the schema it is given', () async { final status = await postgrest.rpc.value( 'get_status', diff --git a/packages/postgrest/test/typed_rpc_test.dart b/packages/postgrest/test/typed_rpc_test.dart index e883f14e5..0f1df2180 100644 --- a/packages/postgrest/test/typed_rpc_test.dart +++ b/packages/postgrest/test/typed_rpc_test.dart @@ -161,6 +161,119 @@ void main() { }); }); + test('sends a read-only call as a get request', () async { + httpClient.stub(bookRows); + + await client.rpc + .rows( + 'search_books', + arguments: { + 'query': 'dart', + 'tags': ['a', 'b,c'], + }, + rowFromJson: Book.new, + get: true, + ) + .where(Books.id.gt(1)); + + expect(lastRequest().method, HttpMethod.get.value); + expect(lastRequest().url.queryParameters, { + 'query': 'dart', + 'tags': '{a,"b,c"}', + 'id': 'gt.1', + }); + }); + + test('sends a read-only call with an argument a query parameter cannot ' + 'carry as a post request', () async { + httpClient.stub(bookRows); + + for (final query in ['eq.dart', 'not.in.(a)', 'fts(english).dart']) { + await client.rpc.rows( + 'search_books', + arguments: {'query': query}, + rowFromJson: Book.new, + get: true, + ); + + expect(lastRequest().method, HttpMethod.post.value); + expect(lastRequest().jsonBody, {'query': query}); + } + + await client.rpc.rows( + 'search_books', + arguments: {'limit': 2}, + rowFromJson: Book.new, + get: true, + ); + expect(lastRequest().method, HttpMethod.post.value); + expect(lastRequest().jsonBody, {'limit': 2}); + + await client.rpc.rows( + 'search_books', + arguments: {'query': null}, + rowFromJson: Book.new, + get: true, + ); + expect(lastRequest().method, HttpMethod.post.value); + expect(lastRequest().jsonBody, {'query': null}); + + await client.rpc.rows( + 'search_books', + arguments: {'query': 'equal.parts'}, + rowFromJson: Book.new, + get: true, + ); + expect(lastRequest().method, HttpMethod.get.value); + }); + + test('retries a read-only call', () async { + httpClient.stubStatuses([503, 200], body: bookRows); + final retrying = PostgrestClient( + 'http://localhost/rest/v1', + httpClient: httpClient, + retryOptions: const SupabaseRetryOptions(initialDelay: Duration.zero), + ); + addTearDown(retrying.dispose); + + final books = await retrying.rpc + .rows('search_books', rowFromJson: Book.new, get: true) + .retry(count: 1); + + expect(books, hasLength(2)); + expect(httpClient.requests, hasLength(2)); + }); + + test('does not retry a call that is not read-only', () async { + httpClient.stubStatuses([503, 200], body: bookRows); + final retrying = PostgrestClient( + 'http://localhost/rest/v1', + httpClient: httpClient, + retryOptions: const SupabaseRetryOptions(initialDelay: Duration.zero), + ); + addTearDown(retrying.dispose); + + await expectLater( + () => retrying.rpc + .rows('search_books', rowFromJson: Book.new) + .retry(count: 1), + throwsA(isA()), + ); + expect(httpClient.requests, hasLength(1)); + }); + + test('rejects a read-only call with arguments that are not a map', () { + expect( + () => client.rpc.rows( + 'search_books', + arguments: ['dart'], + rowFromJson: Book.new, + get: true, + ), + throwsArgumentError, + ); + }); + test('calls in the schema it is given', () async { httpClient.stub(bookRows); @@ -211,6 +324,33 @@ void main() { expect(lastRequest().jsonBody, {'kind': 'click'}); }); + test('sends a read-only call as a get request', () async { + httpClient.stub(3); + + await client.rpc.value( + 'count_books', + arguments: {'author_id': 1}, + fromJson: (json) => json as int?, + get: true, + ); + + expect(lastRequest().method, HttpMethod.get.value); + expect(lastRequest().url.queryParameters, {'author_id': '1'}); + }); + + test('sends a read-only call without arguments as a get request', () async { + httpClient.stub(3); + + await client + .schema('inventory') + .rpc + .value('count_books', fromJson: (json) => json as int?, get: true); + + expect(lastRequest().method, HttpMethod.get.value); + expect(lastRequest().url.queryParameters, isEmpty); + expect(lastRequest().headers['accept-profile'], 'inventory'); + }); + test('converts a list of scalars', () async { httpClient.stub([1, 2, null]); diff --git a/packages/supabase_typegen/lib/src/dart_generator.dart b/packages/supabase_typegen/lib/src/dart_generator.dart index 7adebee05..bf601d33e 100644 --- a/packages/supabase_typegen/lib/src/dart_generator.dart +++ b/packages/supabase_typegen/lib/src/dart_generator.dart @@ -1773,10 +1773,43 @@ void _writeFunctionMethod( } buffer ..writeln(' ${call.converter},') - ..writeln(' schema: ${_stringLiteral(function.schema)},') - ..writeln(' );'); + ..writeln(' schema: ${_stringLiteral(function.schema)},'); + if (!overload.isVolatile && arguments.every(_isQueryParameter)) { + buffer.writeln(' get: true,'); + } + buffer.writeln(' );'); +} + +/// Whether [argument] can be sent as a query parameter, as a read-only call +/// sends its arguments: it is named, PostgREST does not read the name as a +/// query option or embed path, and it is neither a row nor `json`, which only +/// a request body carries as JSON. +bool _isQueryParameter(FunctionArgumentDescription argument) { + bool isJson(ColumnTypeKind? kind) => + kind == ColumnTypeKind.json || kind == ColumnTypeKind.unknown; + final type = argument.type; + final name = argument.name; + return name.isNotEmpty && + !name.contains('.') && + !_reservedQueryParameters.contains(name) && + argument.rowOf == null && + !isJson(type.typeKind) && + !isJson(type.elementTypeKind); } +/// The query parameters PostgREST reads as options of the request rather than +/// as arguments of a function. +const _reservedQueryParameters = { + 'select', + 'columns', + 'on_conflict', + 'order', + 'limit', + 'offset', + 'and', + 'or', +}; + /// How the generated method of a function calls `PostgrestRpc`: the type it /// returns, the `rows` or `value` method it calls with the converter argument /// for it, and what the result is in its documentation, empty when the diff --git a/packages/supabase_typegen/lib/src/generator_metadata_parser.dart b/packages/supabase_typegen/lib/src/generator_metadata_parser.dart index 100ac9163..73a89f04d 100644 --- a/packages/supabase_typegen/lib/src/generator_metadata_parser.dart +++ b/packages/supabase_typegen/lib/src/generator_metadata_parser.dart @@ -74,8 +74,10 @@ ColumnTypeKind _typeKind(String format, {required bool isEnum}) { /// only the computed fields and computed relationships are read: functions /// whose single input argument is the row type of a described relation of /// the same schema. The functions callable through `/rpc` come from the -/// `rpcFunctions` collection; a document without it describes none. Fields -/// the generator does not need are ignored. +/// `rpcFunctions` collection; a document without it describes none. Their +/// volatility is the `behavior` of the `functions` entry an overload's +/// `function_id` names, and volatile when there is none. Fields the +/// generator does not need are ignored. /// /// Tables and foreign tables are always insertable and updatable. Views use /// the `is_insert_enabled` and `is_update_enabled` flags, falling back to @@ -645,6 +647,12 @@ List _functions( }) { final rpcFunctions = (document['rpcFunctions'] as List? ?? const []) .cast>(); + final behaviorsById = { + for (final function + in (document['functions'] as List? ?? const []) + .cast>()) + function['id'] as int: function['behavior'] as String?, + }; ValueTypeDescription valueType(Map reference) => _valueType( typesById[reference['type_id'] as int], @@ -717,6 +725,13 @@ List _functions( result: result(overload), error: overload['error'] as String?, isComputedField: overload['computed_field_of'] != null, + isVolatile: switch (overload['function_id']) { + final int id => switch (behaviorsById[id]) { + 'STABLE' || 'IMMUTABLE' => false, + _ => true, + }, + _ => true, + }, ), ], ), diff --git a/packages/supabase_typegen/lib/src/schema_description.dart b/packages/supabase_typegen/lib/src/schema_description.dart index 697d03943..2ab418cc1 100644 --- a/packages/supabase_typegen/lib/src/schema_description.dart +++ b/packages/supabase_typegen/lib/src/schema_description.dart @@ -410,6 +410,7 @@ class FunctionOverloadDescription { required this.result, this.error, this.isComputedField = false, + this.isVolatile = true, }); /// The input parameters, in name order. @@ -426,6 +427,10 @@ class FunctionOverloadDescription { /// Whether the function is a computed field of a relation of its schema, /// selectable through the relation's computed fields. final bool isComputedField; + + /// Whether the function is declared `VOLATILE`, so it may write to the + /// database, rather than `STABLE` or `IMMUTABLE`. + final bool isVolatile; } /// An input parameter of a [FunctionOverloadDescription]. diff --git a/packages/supabase_typegen/test/dart_generator_test.dart b/packages/supabase_typegen/test/dart_generator_test.dart index 72057f369..3df7ebb49 100644 --- a/packages/supabase_typegen/test/dart_generator_test.dart +++ b/packages/supabase_typegen/test/dart_generator_test.dart @@ -1659,6 +1659,90 @@ void main() { ); }); + test('a stable function is called read-only unless an argument only ' + 'fits in a request body', () { + FunctionDescription stable( + String name, + ValueTypeDescription type, + ) => FunctionDescription( + schema: 'public', + name: name, + overloads: [ + FunctionOverloadDescription( + arguments: [ + argument('id'), + FunctionArgumentDescription( + name: 'extra', + type: type, + hasDefault: true, + ), + ], + result: const FunctionNoResult(), + isVolatile: false, + ), + ], + ); + + final code = _normalize( + generateDartCode( + withFunctions([ + stable('with_integers', integer), + stable( + 'with_json', + const ValueTypeDescription( + postgresFormat: 'jsonb', + typeKind: ColumnTypeKind.json, + ), + ), + stable( + 'with_json_array', + const ValueTypeDescription( + postgresFormat: '_jsonb', + typeKind: ColumnTypeKind.array, + elementTypeKind: ColumnTypeKind.json, + ), + ), + FunctionDescription( + schema: 'public', + name: 'volatile', + overloads: [ + FunctionOverloadDescription( + arguments: [argument('id')], + result: const FunctionNoResult(), + ), + ], + ), + ]), + ), + ); + + final limited = _normalize( + generateDartCode( + withFunctions([ + FunctionDescription( + schema: 'public', + name: 'with_limit', + overloads: [ + FunctionOverloadDescription( + arguments: [argument('limit')], + result: const FunctionNoResult(), + isVolatile: false, + ), + ], + ), + ]), + ), + ); + expect(limited, isNot(contains('get:'))); + + String call(String name) => + RegExp("value\\( '$name'.*?\\);").firstMatch(code)![0]!; + expect(call('with_integers'), contains('get: true')); + expect(call('with_json'), isNot(contains('get:'))); + expect(call('with_json_array'), isNot(contains('get:'))); + expect(call('volatile'), isNot(contains('get:'))); + }); + test('the overload with the fewest arguments keeps the plain name', () { final code = _normalize( generateDartCode( diff --git a/packages/supabase_typegen/test/generated_schema_behavior_test.dart b/packages/supabase_typegen/test/generated_schema_behavior_test.dart index 5f10eb5cf..8610197f2 100644 --- a/packages/supabase_typegen/test/generated_schema_behavior_test.dart +++ b/packages/supabase_typegen/test/generated_schema_behavior_test.dart @@ -638,13 +638,47 @@ void main() { .order(Books.title.asc()); expect(books.single.mood, Mood.veryHappy); - expect(lastRequest().method, HttpMethod.post.value); - expect(lastRequest().jsonBody, {'query': 'typed', 'mood': 'very happy'}); + expect(lastRequest().method, HttpMethod.get.value); expect(lastRequest().url.queryParameters, { + 'mood': 'very happy', + 'query': 'typed', 'id': 'gt.0', 'order': 'title.asc', }); - expect(lastRequest().headers['content-profile'], 'public'); + expect(lastRequest().headers['accept-profile'], 'public'); + }); + + test('a stable function is called read-only and retried', () async { + httpClient.stubStatuses([503, 200], body: 3); + final retrying = PostgrestClient( + 'http://localhost/rest/v1', + httpClient: httpClient, + retryOptions: const SupabaseRetryOptions(initialDelay: Duration.zero), + ); + addTearDown(retrying.dispose); + + final int? count = await retrying.rpc.countBooks().retry(count: 1); + + expect(count, 3); + expect(httpClient.requests, hasLength(2)); + expect(lastRequest().method, HttpMethod.get.value); + }); + + test('a volatile function is not retried', () async { + httpClient.stubStatuses([503, 200], body: null); + final retrying = PostgrestClient( + 'http://localhost/rest/v1', + httpClient: httpClient, + retryOptions: const SupabaseRetryOptions(initialDelay: Duration.zero), + ); + addTearDown(retrying.dispose); + + await expectLater( + () => retrying.rpc.touchBook(bookId: 2).retry(count: 1), + throwsA(isA()), + ); + expect(httpClient.requests, hasLength(1)); + expect(lastRequest().method, HttpMethod.post.value); }); test('a function of another schema is called in its schema', () async { @@ -710,6 +744,7 @@ void main() { book: BooksRow({'id': 1, 'title': 'A typed row'}), ); expect(mood, Mood.sad); + expect(lastRequest().method, HttpMethod.post.value); expect(lastRequest().jsonBody, { 'book': {'id': 1, 'title': 'A typed row'}, }); @@ -739,19 +774,23 @@ void main() { httpClient.stub([]); await client.rpc.booksOf(authorId: 1); - expect(lastRequest().jsonBody, {'author_id': 1}); + expect(lastRequest().url.queryParameters, {'author_id': '1'}); await client.rpc.booksOfWithAuthorNameAndMaxPrice( authorName: 'Ada', maxPrice: 10, ); - expect(lastRequest().jsonBody, {'author_name': 'Ada', 'max_price': 10}); + expect(lastRequest().url.queryParameters, { + 'author_name': 'Ada', + 'max_price': '10', + }); }); test('a sole unnamed json parameter is sent as the whole body', () async { httpClient.stub({'echoed': true}); final echoed = await client.rpc.echo({'echoed': true}); expect(echoed, {'echoed': true}); + expect(lastRequest().method, HttpMethod.post.value); expect(lastRequest().jsonBody, {'echoed': true}); }); diff --git a/packages/supabase_typegen/test/generator_metadata_parser_test.dart b/packages/supabase_typegen/test/generator_metadata_parser_test.dart index 3981fbc51..852c994f2 100644 --- a/packages/supabase_typegen/test/generator_metadata_parser_test.dart +++ b/packages/supabase_typegen/test/generator_metadata_parser_test.dart @@ -1351,6 +1351,13 @@ void main() { expect(overload('search_books').error, isNull); }); + test('reads the volatility of every overload', () { + expect(overload('restock').isVolatile, isTrue); + expect(overload('touch_book').isVolatile, isTrue); + expect(overload('search_books').isVolatile, isFalse); + expect(overload('echo').isVolatile, isFalse); + }); + test('lists the functions of the named schemas only', () { final public = parseGeneratorMetadata(document, schemaNames: ['public']); diff --git a/packages/supabase_typegen/test/goldens/supabase_schema.dart b/packages/supabase_typegen/test/goldens/supabase_schema.dart index 3f2f8370c..8c606ad02 100644 --- a/packages/supabase_typegen/test/goldens/supabase_schema.dart +++ b/packages/supabase_typegen/test/goldens/supabase_schema.dart @@ -819,6 +819,7 @@ extension DatabaseFunctions on PostgrestRpc { arguments: {'min_books': ?minBooks}, rowFromJson: AuthorBookCountsRow.new, schema: 'public', + get: true, ); /// Calls the `book_by_id` function, which returns a row of `books`, or `null` @@ -833,6 +834,7 @@ extension DatabaseFunctions on PostgrestRpc { _ => null, }, schema: 'public', + get: true, ); /// Calls the `books_of` function, which returns rows of `books` filterable @@ -844,6 +846,7 @@ extension DatabaseFunctions on PostgrestRpc { arguments: {'author_id': authorId}, rowFromJson: BooksRow.new, schema: 'public', + get: true, ); /// Calls the `books_of` function, which returns rows of `books` filterable @@ -857,6 +860,7 @@ extension DatabaseFunctions on PostgrestRpc { arguments: {'author_name': authorName, 'max_price': maxPrice}, rowFromJson: BooksRow.new, schema: 'public', + get: true, ); /// Calls the `books_with_tags` function, which returns rows of `books` @@ -868,11 +872,16 @@ extension DatabaseFunctions on PostgrestRpc { arguments: {'tags': tags}, rowFromJson: BooksRow.new, schema: 'public', + get: true, ); /// Calls the `count_books` function. - PostgrestTypedBuilder countBooks() => - value('count_books', fromJson: (json) => json as int?, schema: 'public'); + PostgrestTypedBuilder countBooks() => value( + 'count_books', + fromJson: (json) => json as int?, + schema: 'public', + get: true, + ); /// Calls the `echo` function. PostgrestTypedBuilder echo(Object? body) => value( @@ -901,6 +910,7 @@ extension DatabaseFunctions on PostgrestRpc { element == null ? null : _postgrestDateFromJson(element), ], schema: 'public', + get: true, ); /// Calls the `search_books` function, which returns rows of `books` @@ -918,6 +928,7 @@ extension DatabaseFunctions on PostgrestRpc { }, rowFromJson: BooksRow.new, schema: 'public', + get: true, ); /// Calls the `touch_book` function.