Skip to content

Commit ea5ba31

Browse files
Sadman Sakib Hasanssh24
Sadman Sakib Hasan
authored andcommitted
Merge branch 'master' into update-test-readme
2 parents 4d5e986 + 17ce7b5 commit ea5ba31

File tree

2 files changed

+35
-8
lines changed

2 files changed

+35
-8
lines changed

README.md

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -350,13 +350,40 @@ Destroying models may result in errors due to foreign key integrity. First delet
350350

351351
## Running tests
352352

353-
You will need a postgres database created locally and a user with full read/write access to the database (substitute as required with values appropriate to your setup):
353+
**Install postgresql locally**
354354

355-
1. `CI=true PGHOST=localhost PGPORT=<pgport> PGDATABASE=<dbname> PGUSER=<username> PGPASSWORD=<password> npm test`
355+
<https://www.postgresql.org/download/macosx/>
356356

357-
The defaults are:
357+
**Set up the database**
358358

359-
Host | Port | Database | User | Password
360-
--- | --- | --- | --- | ----
361-
localhost | 5432 | emptytest | test | _none_
359+
1. Go to pgAdmin.<br>
360+
By default, the local database is one of the servers under Server Groups > Servers.
361+
2. Under Login Roles, add a user called `strongloop`.
362362

363+
**Change configuration for database connection (Choose either of step 1 or 2)**
364+
365+
1. In `test\init.js`, change the value of `config` to be pointing to the local database and then run `npm test`. For example,
366+
367+
```
368+
var config = {
369+
host: 'localhost',
370+
port: '5432',
371+
database:'strongloop',
372+
username: 'postgres',
373+
password: 'postgres',
374+
};
375+
```
376+
377+
2. (`Linux Only`) `CI=true PGHOST=localhost PGPORT=<pgport> PGDATABASE=<dbname> PGUSER=<username> PGPASSWORD=<password> npm test`
378+
379+
**Troubleshooting**
380+
381+
When running npm test, it runs the `pretest.js` which eventually runs `schema.sql` to set up the database and tables. If there is problem, you can run the `schema.sql` manually. To do this:
382+
383+
1. Go to SQL Shell (psql)
384+
2. Run:
385+
```
386+
\i <<file path>>
387+
388+
For example on Windows, \i c:/somepath/test/schema.sql
389+
```

lib/postgresql.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,10 +387,10 @@ PostgreSQL.prototype.buildExpression = function(columnName, operator,
387387
operatorValue, propertyDefinition) {
388388
switch (operator) {
389389
case 'like':
390-
return new ParameterizedSQL(columnName + " LIKE ? ESCAPE '\\'",
390+
return new ParameterizedSQL(columnName + " LIKE ? ESCAPE E'\\\\'",
391391
[operatorValue]);
392392
case 'nlike':
393-
return new ParameterizedSQL(columnName + " NOT LIKE ? ESCAPE '\\'",
393+
return new ParameterizedSQL(columnName + " NOT LIKE ? ESCAPE E'\\\\'",
394394
[operatorValue]);
395395
case 'regexp':
396396
if (operatorValue.global)

0 commit comments

Comments
 (0)