Skip to content

Cannot setup a attachments table with a custom name #522

@jessemcintire

Description

@jessemcintire

Hi all!

The following query error occurs when attempting to name the attachments table anything other than attachments per this Readme.

[PowerSyncDatabase] [Error: [react-native-quick-sqlite] SQL execution error: no such table: attachments]

Ran into this issue when building out support for saving attachments to more than one storage bucket. I have two storage buckets named items and `avatars and set my attachments table schemas with:

items: new AttachmentTable({
  name: 'items',
}),
avatars: new AttachmentTable({
  name: 'avatars',
})

And have set this.options.attachmentDirectoryName in each related attachment queue class. But I still get the same error.

Looking at the source for @powersync/attachments, I see that this line is hardcoded to always use the attachments db table.

Updating it to this fixes the issue:

return this.options.attachmentDirectoryName || ATTACHMENT_TABLE;

Should I open a PR for this update?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions