loopbackio / loopbackio/loopback-connector-postgresql
Properties with underscores in their name cannot be indexed
Open
Nobody has claimed this yet.
bug
good first issue
help wanted
- Dominant language
- JavaScript
- Stars
- 118
- Forks
- 184
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 5
Description
Steps to reproduce
- create a model with a property name that contains an underscore in it (e.g. short_name).
- set that property to be indexed (e.g.
"index": true) - call
pg.autoupdate()(e.g. whereapp.datasources.pg);
Current Behavior
- The index is added
- Then the index is dropped
Expected Behavior
- The index is added
Additional information
The bug shown here is a bad regular expression in migration.js (on or about line 777):
const propNameRegEx = new RegExp('^' + self.table(model) + '_([^_]+)_idx');
The simple fix is:
const propNameRegEx = new RegExp('^' + self.table(model) + '_(.*)(?:_idx)$');
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in migration.js around line 777 and reproduce the reported model setup with an underscored property, then call pg.autoupdate(). Verify that the existing index remains after migration and that the property name is matched correctly when it contains underscores.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, postgresql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100