supabase_schema_core 1.10.1
supabase_schema_core: ^1.10.1 copied to clipboard
Internal package for Supabase schema fetching and type mapping. Used by supafreeze and suparepo. Not intended for direct use.
Changelog #
1.10.1 - 2026-06-28 #
Fixed #
- OpenAPI table introspection now reports defaults/nullability correctly. Follow-up to 1.10.0, which first made the OpenAPI table path reachable.
- A NOT NULL column with a default is no longer marked nullable. PostgREST omits such columns from the
requiredlist (they are optional on insert), so!required.contains(col)alone was wrong; the presence of a default now also implies non-nullable. - String defaults are normalized to the single-quoted PG-literal form (
JPY→'JPY') so consumers that parsecolumn_defaultrecognize them. Expression defaults (gen_random_uuid(),now()) stay unquoted and are treated as non-literal.
- A NOT NULL column with a default is no longer marked nullable. PostgREST omits such columns from the
1.10.0 - 2026-06-28 #
Fixed #
- OpenAPI spec fetch no longer fails with HTTP 400. The request appended
?apikey=<key>to/rest/v1/, which PostgREST parsed as a column filter (PGRST100). The key is already sent as a header, so the redundant query parameter is dropped. This previously aborted all RPC return-type introspection. - Catalog introspection works with an aggregating
execute_sql. RPC/enum introspection queries wrap their projection injson_agg(sub); anexecute_sqlthat itself aggregates rows withjsonb_agg(t)(rather than the README'sEXECUTE ... INTOsingle-row form) double-wrapped the result as[{"json_agg": [...]}], throwingtype 'Null' is not a subtype of type 'String'. Responses are now normalized for both conventions.
Added #
SchemaFetcher.rowsFromAggregatedResponse— normalizes a rawexecute_sqlresponse into the innerjson_aggrow list under eitherexecute_sqlconvention.SchemaFetcher.applyResultModels— merges consumerresult_modelscolumn overrides onto introspected RPC columns (overrides set type/nullability; unmentioned introspected columns are retained).
1.9.0 - 2026-06-26 #
Added #
RpcTableColumn.nullable— new field (defaultfalse) marking whether aRETURNS TABLEcolumn may be null in the result row. Introspection cannot infer nullability frompg_proc, so it staysfalsefor introspected columns and is intended to be overridden via consumers' YAMLresult_modelsdefinitions.toString()now includes the flag.
1.8.0 - 2026-05-19 #
Added #
SqlMigrationParser— pure-Dart parser for local SQL migration files. Extracts RPC return-type info fromCREATE [OR REPLACE] FUNCTION ... RETURNS ...statements andCREATE TYPE ... AS (...)composite types, with no database round-trip. Supports:- Scalar returns (
RETURNS BOOLEAN,TEXT,UUID,INTEGER,BIGINT, etc.) RETURNS TABLE(col1 type1, ...)RETURNS SETOF <type>(including composite types resolved to typed columns)- Dollar-quoted bodies (correctly ignores
CREATE FUNCTIONtext inside function bodies /RAISE NOTICEstrings) - Line (
--) and block (/* */) comments - Trigger functions are skipped (not RPC-callable)
- Scalar returns (
SchemaFetcher.mergeSqlMigrationInfo— merges parser results into the function list, filling in only those still resolved tovoid
Changed #
- The execute_sql failure warning now lists
rpc.migrations_pathas the recommended workaround alongside the existing options
1.7.3 - 2026-05-19 #
Added #
SchemaFetcher.warningsgetter that exposes non-fatal diagnostics collected during the lastfetchRpcFunctions()call (e.g.execute_sqlintrospection failures, suspiciously high ratio of RPC functions resolved tovoid)parseRpcFunctionsnow resolves$refschemas againstdefinitions/components.schemasand falls back to OpenAPI 3.0responses.200.content.<mediaType>.schemawhen Swagger 2.0responses.200.schemais absent
Fixed #
- When
execute_sqlRPC is not available,fetchRpcFunctions()no longer silently degrades toFuture<void>for every RPC. A clear warning is recorded explaining the failure and pointing torpc.return_typesas a workaround (fixes #2)
1.7.2 - 2026-04-08 #
Fixed #
- Fix
_resolveTypeorder:coalesce/NOT/EXISTSchecks now run before::cast detection, preventing::typeinside nested subqueries from being misidentified as the expression type - Harden
parseJsonBuildObjectand_tokenizeBuildObjectArgsto skip SQL string literals during parenthesis depth tracking
1.7.1 - 2026-04-08 #
Fixed #
- Improve
_resolveTypeto infer types from complex SQL expressions:coalesce(..., false/true)→boolcoalesce(..., 0)→int4NOT expr→boolEXISTS(...)→bool- Boolean operators (
AND,OR,IS NULL) →bool
1.7.0 - 2026-04-08 #
Added #
RpcTableColumn.nestedColumnsandisArrayfields for nested JSON structureSchemaFetcher.parseNestedJsonColumns()— parsesjson_agg(json_build_object(...))patterns to extract nested column schemas with alias matchingSchemaFetcher._fetchRpcNestedJsonColumns()— auto-detects nested structures for RETURNS TABLE json columns
1.6.0 - 2026-04-08 #
Added #
SchemaFetcher.parseRpcErrorCodes()— parses PL/pgSQL function source to extract snake_case error code literals fromreturn query select false, 'code'::textanderror := 'code'patternsRpcFunctionInfo.errorCodesfield for detected error codesSchemaFetcher._fetchRpcErrorCodes()— queriespg_proc.prosrcfor functions witherror textcolumns inRETURNS TABLE
1.5.2 - 2026-04-08 #
Added #
TypeMapper.isJsonType()— returns true forjson/jsonbPostgreSQL types, allowing callers to scopedynamicmapping to specific contexts (e.g. RPC result models) instead of globally
Fixed #
- Revert
json/jsonbmapping back toMap<String, dynamic>inTypeMapper— the globaldynamicchange in v1.5.1 was too broad; callers that needdynamicshould useisJsonType()to decide
1.5.1 - 2026-04-08 #
Fixed #
- Map
json/jsonbPostgreSQL types todynamicinstead ofMap<String, dynamic>— JSON values can be arrays (json_agg), objects, or scalars, sodynamicis the safe Dart type
1.5.0 - 2026-04-08 #
Added #
- Auto-detect JSON column schemas from
json_build_object()/jsonb_build_object()in PL/pgSQL function bodies viapg_proc.prosrc SchemaFetcher.parseJsonBuildObject()— parses function source to extract key names and infer types from variable declarationsSchemaFetcher._fetchRpcJsonColumns()— queriespg_procforRETURNS json/jsonbfunctions and auto-detects column schemas
1.4.2 - 2026-04-03 #
Added #
TypeMapper.isDateTimeType()— checks whether a PostgreSQL type (date,timestamp,timestamptz) maps to DartDateTimeTypeMapper.isDateOnlyType()— checks whether a PostgreSQL type is date-only (date) with no time component
1.4.1 - 2026-03-11 #
Fixed #
- Fix
mergeEnumTypesfailing to match OpenAPI-derived enum names (tableName_columnNameformat) to pg_enum names, resulting indynamictype- Add
openApiEnumsparameter to retain OpenAPI enum info before TypeMapper is cleared
- Add
1.4.0 - 2026-03-11 #
Added #
EnumInfoclass for representing PostgreSQL enum types (name + values)SchemaFetcher.fetchEnums()— queriespg_enum+pg_type+pg_namespacecatalog to fetch PostgreSQL enum definitions; falls back to OpenAPI-detected enums whenexecute_sqlis not availableSchemaFetcher.mergeEnumTypes()static method — replaces OpenAPI-derived enum type names (tableName_columnName) with actual PostgreSQL type names in table column definitionsTypeMapper.useEnumTypesstatic flag — whentrue,mapType()returns PascalCase Dart enum type names instead ofStringfor registered enum typesTypeMapper.enumTypeName()— converts PostgreSQL enum type name to Dart enum type name (e.g.campaign_type→CampaignType)
1.3.0 - 2026-03-03 #
Added #
RpcTableColumnclass for representing columns inRETURNS TABLE(...)definitionsRpcFunctionInfo.tableColumnsfield — non-null when the function usesRETURNS TABLE(col1 type1, ...)SchemaFetcher._fetchRpcTableColumns()— queriespg_proccatalog (proargmodes,proargnames,proallargtypes) to extract TABLE column names and typesSchemaFetcher.mergeTableColumns()static method to merge TABLE column info intoRpcFunctionInfolistfetchRpcFunctions()now callsmergeTableColumnsaftermergeReturnTypesto populatetableColumnsfor RETURNS TABLE functions
1.2.2 - 2026-03-03 #
Fixed #
mergeReturnTypes()now correctly handlesRETURNS TABLE(...)functions — previously treated asvoidbecausepg_procreports them asrecordtype, now detected assetof jsonbwhenproretset = true
1.2.1 - 2026-02-23 #
Fixed #
_fetchRpcReturnTypes()now wraps thepg_procquery withjson_aggso thatexecute_sql(which usesEXECUTE ... INTO) returns all rows as a single JSON array instead of only the first row
1.2.0 - 2026-02-23 #
Added #
RpcFunctionInfo.copyWith()method for updating return type fieldsSchemaFetcher.mergeReturnTypes()static method to correctvoidreturn types usingpg_proccatalogSchemaFetcher._fetchRpcReturnTypes()to querypg_procfor accurate return type information
Changed #
fetchRpcFunctions()now queriespg_proccatalog to correct scalar return types (e.g.bool,int4) that PostgREST OpenAPI spec reports as empty schema (void)- Only active when
execute_sqlRPC function is available - Falls back to OpenAPI-only behavior when
execute_sqlis not configured
- Only active when
1.1.0 - 2026-02-11 #
Added #
RpcParamInfoclass for representing RPC function parametersRpcFunctionInfoclass for representing RPC function metadataSchemaFetcher.fetchRpcFunctions()to fetch RPC function definitions from OpenAPI specSchemaFetcher.parseRpcFunctions()to parse RPC functions from OpenAPI JSON
Changed #
- Extracted
_fetchOpenApiSpec()as a shared method for both table and RPC fetching