Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated userModels.js can't handle columns with question marks #190

Open
mrjogo opened this issue Aug 3, 2024 · 4 comments
Open

Generated userModels.js can't handle columns with question marks #190

mrjogo opened this issue Aug 3, 2024 · 4 comments

Comments

@mrjogo
Copy link

mrjogo commented Aug 3, 2024

Some of Supabase's built-in tables (specifically _analytics.users) have column names with question marks (ie, lifetime_plan?). Seed's codegen doesn't handle it properly, and generates the following invalid javascript in userModels.js:

billing_accounts: {
  data: {
    id: null,
    latest_successful_stripe_session: fallbackFunctionTagger(({ seed, options }) => { return ({ [copycat.word(seed)]: copycat.words(seed) }) }),
    stripe_customer: fallbackFunctionTagger(({ seed, options }) => { return copycat.sentence(seed, options).slice(0, 255) }),
    user_id: fallbackFunctionTagger(({ seed, options }) => { return copycat.int(seed, { ...{"min":0,"max":16777215}, ...options }) }),
    inserted_at: fallbackFunctionTagger(({ seed, options }) => { return copycat.dateString(seed, { ...{"minYear":2020}, ...options }) }),
    updated_at: fallbackFunctionTagger(({ seed, options }) => { return copycat.dateString(seed, { ...{"minYear":2020}, ...options }) }),
    stripe_subscriptions: fallbackFunctionTagger(({ seed, options }) => { return ({ [copycat.word(seed)]: copycat.words(seed) }) }),
    stripe_invoices: fallbackFunctionTagger(({ seed, options }) => { return ({ [copycat.word(seed)]: copycat.words(seed) }) }),
    lifetime_plan?: fallbackFunctionTagger(({ seed, options }) => { return copycat.bool(seed) }),
    lifetime_plan_invoice: fallbackFunctionTagger(({ seed, options }) => { return copycat.sentence(seed, options).slice(0, 255) }),
    default_payment_method: fallbackFunctionTagger(({ seed, options }) => { return copycat.sentence(seed, options).slice(0, 255) }),
    custom_invoice_fields: fallbackFunctionTagger(({ seed, options }) => { return [({ [copycat.word(seed)]: copycat.words(seed) })] }),
    lifetime_plan: fallbackFunctionTagger(({ seed, options }) => { return copycat.bool(seed) })
  }
},

which results in an error when trying to run: node_modules/@snaplet/seed/dist/assets/userModels.js:52:17: ERROR: Expected "}" but found "?"

@Silur
Copy link

Silur commented Aug 18, 2024

encountered the exact same issue, any update on this?

@ronthedrummer
Copy link

Also experiencing this. Trying to use Snaplet and I can't get it to work.

@peterp
Copy link
Collaborator

peterp commented Aug 31, 2024

@mrjogo: You can try defining "lifetime_plan?" as a literal string, e.g.:

billing_accounts: {
  data: {
      'lifetime_plan?': "..."
  }

@mrjogo
Copy link
Author

mrjogo commented Aug 31, 2024

I didn't write that file, it was autogenerated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants