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

Extend Aliased Field Definitions to include SQL #252

Closed
MrSwitch opened this issue Oct 21, 2022 · 1 comment · Fixed by #253
Closed

Extend Aliased Field Definitions to include SQL #252

MrSwitch opened this issue Oct 21, 2022 · 1 comment · Fixed by #253
Labels

Comments

@MrSwitch
Copy link
Member

Currently An Aliased field definition maps one field to another (incase of name change). However this proposal is for an alias field definition which includes other SQL syntax. So can do more than simply map to another field.

e.g. in the model below hasCondition is defined as a SQL statement

schema: {
   hasCondition: '!ISNULL(condition)`,
   // ... other field definitions
}

We would then be able to use hasCondition in sql columns....

dare.get('team', [..., 'hasCondition']);
// SELECT ..., !ISNULL(condition) AS 'hasCondition' LIMIT 1

(note: we can do that already with generated functions. However they can only be applied on response values.)

Aliased SQL syntax could also be applied as the filter

dare.getCount('team', {
    hasCondition: true
});
// SELECT ... WHERE (!ISNULL(condition)) = true

Granted the SQL might be ugly but powerful as could also be used in the negative (replace true with false in above codeblock)...

note: As with Generated FIelds, this would be limited to query fields and filters (not INSERT or SET key=>values)

MrSwitch added a commit that referenced this issue Oct 22, 2022
feat(alias-sql): filter by an aliased field definition, #252
5app-Machine added a commit that referenced this issue Oct 22, 2022
# [0.69.0](v0.68.1...v0.69.0) (2022-10-22)

### Features

* **alias-sql:** filter by an aliased field definition, [#252](#252) ([d92b2b2](d92b2b2))
@5app-Machine
Copy link
Contributor

🎉 This issue has been resolved in version 0.69.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging a pull request may close this issue.

2 participants