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

remove prepare/consume from data column #4

Merged
merged 2 commits into from
Aug 17, 2022

Conversation

justDare
Copy link
Contributor

Proposed changes

Removes data column consume/prepare methods that were breaking reading notifications created by NotificationContracts. Issue can be found here: #3

Types of changes

What types of changes does your code introduce?

Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have read the CONTRIBUTING doc
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added necessary documentation (if appropriate)

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...

@arthur-er
Copy link
Member

Can you confirm that it works in sqlite?

@justDare
Copy link
Contributor Author

justDare commented Aug 12, 2022

Yea don't merge this, I ran a project locally and the responses are coming back as strings with sqlite, that might be an adonis issue. They should probably parse json the same no matter the driver.... However it looks like sqlite is the only db that has this issue so you're probably better off with this for now.

Screen Shot 2022-08-12 at 5 32 12 PM

@justDare
Copy link
Contributor Author

A work around could be applying the decorators conditionally based on the driver. Another idea is overriding columns from the user model, but I'm not good enough with mixins to figure out how to pass options to the data column from the user model composing it.

@arthur-er
Copy link
Member

A work around could be applying the decorators conditionally based on the driver. Another idea is overriding columns from the user model, but I'm not good enough with mixins to figure out how to pass options to the data column from the user model composing it.

I think that applying the JSON parse/stringify conditionally based on the type returned by the DB driver can solve the issue, IE:

typeof payload === "string" ? JSON.parse(payload) : payload

It took more time than i imagined to write tests for all databases Lucid support through

@justDare
Copy link
Contributor Author

justDare commented Aug 13, 2022

@arthur-er ya that'll work! Updated it. Quick question while you're here, have you ever tried to type the data column with generics? I'd love to have that field typed to support different notification structures and was wondering if you'd be open to a PR.

So we could have a data: T column and you could type the notifiable mixin to <SomeNotification | AnotherNotification>.

@justDare
Copy link
Contributor Author

@arthur-er this one should be ready to go unless you want anything changed, happy to make updates if you want!

@arthur-er arthur-er merged commit c99048a into verful:master Aug 17, 2022
@justDare justDare deleted the fix-data-decorator branch August 17, 2022 19:28
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

Successfully merging this pull request may close these issues.

2 participants