balderdashy / balderdashy/sails
Updatable VIEWS on MYSQL with Waterline
- Dominant language
- JavaScript
- Stars
- 22.8k
- Forks
- 1.9k
- PR merge metrics
- No merged PRs in 30d
Description
**Node version**: 10.4.1
**Sails version** _(sails)_: 1.1.0
**ORM hook version** _(sails-hook-orm)_: 2.1.1
**DB adapter & version** _(sails-mysql)_: 1.0.1
Hi, i'm trying to update data through a sql view on MySQL 5.7.25 but Waterline keep adding the LIMIT clause to the generated SQL query.
This is the controller relevant portion of code:
```javascript
let updatedQuiz = await VUser.update({
USER_ID: req.body.USER_ID,
ID_REC: req.body.ID_REC
}).set({START_DATE: new Date()});
```
This is the generated SQL query:
```sql
update `V_USER`
set `START_DATE` = '2019-06-18 20:45:08.816',
`MODIFIER_TIMESTAMP` = 1560890708817
where `USER_ID` = 1 and `ID_REC` = 17 limit 9007199254740991
```
This is the resulting error raised from MySQL server
`Incorrect usage of UPDATE and LIMIT`
P.S.: The view uses a multi-table join query
Contributor guide
Research direction
Start with the controller update example and the generated SQL for V_USER; trace the sails-mysql and Waterline update-query path that adds LIMIT. Reproduce the failure against MySQL 5.7.25 using the reported multi-table view, and consider it done when the update no longer raises MySQL's “Incorrect usage of UPDATE and LIMIT” error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, mysql, nodejs
- Domain
- database
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100