balderdashy / balderdashy/sails

Feature request: suppress uniqueness warning about composite unique index

Open
#4,632 11 comments 2 reactions 0 assignees View on GitHub
does this answer your question? orm proposal
Dominant language
JavaScript
Stars
22.8k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

**Waterline version**: 0.13.4
**Node version**: 8.9.1
**NPM version**: 6.0.0
**Operating system**: macOS 10.13.4


I knew Waterline doesn't support **composite index** yet, but we may need unique index on multi columns in some scenarios, for example:
```javascript
// StudentModel
attributes: {
firstname: {
type: 'string',
columnType: 'varchar(50)'
},
lastname: {
type: 'string',
columnType: 'varchar(100)'
},
},
```
```sql
CREATE UNIQUE INDEX ON studentmodel USING BTREE (firstname, lastname)
```
We will get a warning log because uniqueness constraint:
```
Warning: Adapter sent back a uniqueness error, but that error references key(s) (firstname, lastname) which cannotbe matched up with the column names of any attributes in this model (`studentmodel`). This probablymeans there is a bug in this adapter.(Note for adapter implementors: If your adapter doesn't support granular reporting of the keys violatedin uniqueness errors, then just use an empty array for the `keys` property of this error.)(Proceeding anyway as if these keys weren't included...)
```

I saw the logging code:
https://github.com/balderdashy/waterline/blob/master/lib/waterline/utils/query/forge-adapter-error.js#L224

Can we provide a switch to turn off this warning log?

Contributor guide

Open the contributing guide

Research direction

Start at lib/waterline/utils/query/forge-adapter-error.js around line 224, where the issue identifies the uniqueness warning. Trace how adapter errors with multiple keys are handled and identify the existing configuration or entry point for suppressing logs. Done means a switch can suppress this composite-index warning without hiding other uniqueness errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
databases
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.