fix: return user_metadata in list/search responses#952
Open
oniani1 wants to merge 4 commits intosupabase:masterfrom
Open
fix: return user_metadata in list/search responses#952oniani1 wants to merge 4 commits intosupabase:masterfrom
oniani1 wants to merge 4 commits intosupabase:masterfrom
Conversation
Proves that storage.list() does not return user_metadata even though the data exists on the objects table. See supabase#759.
All four search functions (list_objects_with_delimiter, search, search_v2, search_by_timestamp) now include user_metadata in their return types and queries. Folders return NULL for user_metadata. Fixes supabase#759
34d186b to
880d4ac
Compare
PostgreSQL's CREATE OR REPLACE cannot change a function's return type. Added DROP FUNCTION IF EXISTS before each CREATE OR REPLACE, matching the pattern used in migration 0050.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What kind of change does this PR introduce?
Bug fix - resolves #759
What is the current behavior?
storage.list()andlist-v2only return system metadata (size,mimetype,eTag) for each object. Customuser_metadataset during upload is omitted, forcing users to make N additional.info()calls to retrieve it.What is the new behavior?
All list/search endpoints now include
user_metadatain their response. Files return their storeduser_metadata; folders returnnull.Changes
SQL migration (
0059-search-functions-user-metadata.sql):user_metadata jsonbadded to theirRETURNS TABLEandSELECTqueries:storage.list_objects_with_delimiter(used by v2 name-sorted listing)storage.search(used by v1 listing, both name and non-name sorting paths)storage.search_v2(router that delegates to the above)storage.search_by_timestamp(used by v2 timestamp-sorted listing)DROP FUNCTION IF EXISTSis required before eachCREATE OR REPLACEbecause PostgreSQL cannot change a function's return type in-placeNULLforuser_metadatain all code pathsTypeScript (
knex.ts):'user_metadata'to the select array inlistObjectsV2for the non-delimiter direct query path (line 383)Test (
object.test.ts):user_metadatais present on files andnullon foldersVerification
user_metadatavia direct SQL queriesAdditional context
Objschema and route handlers already supporteduser_metadata-- the data just never left the database layeruser_metadatacolumn has existed onstorage.objectssince migration 0025.info()correctly returns it; only the search/list functions were missing itnormalizeColumnsalready stripsuser_metadatafor tenants below migration 25, and migrations run sequentially so the column always exists before this migration