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

Queries with dates are not working #80

Closed
kesavkolla opened this issue May 20, 2015 · 1 comment
Closed

Queries with dates are not working #80

kesavkolla opened this issue May 20, 2015 · 1 comment

Comments

@kesavkolla
Copy link
Contributor

2.x version of loopback-connector-postgresql is failing for simple queries too.

I've the following model:

{
"name": "histrollup",
"base": "PersistedModel",
"idInjection": false,
"options": {
"validateUpsert": true
},
"postgresql": {
"table": "v_histrollup"
},
"properties": {
"property": {
"type": "string",
"id": true,
"required": true,
"postgresql": {
"dataType": "uuid"
}
},
"staydate": {
"type": "date",
"required": true
}
}
}

When I do simple queries on this model things are not working:

app.models.Histrollup.find({where: {property: inputs.property, staydate:new Date('2015-05-01')}, limit:10})

The query that is getting generated for this is:
SQL: SELECT "property","staydate","rolluptype","totnights","totrevenue","bymarketcd","bychannel","byroomtype" FROM "castle"."v_histrollup" WHERE "property"=$1 AND "staydate"$2 ORDER BY "property" LIMIT 10
Parameters: ["c5ba1990-c458-11e4-a8e5-0b887e7b0d20",null]

The date parameter is going as null and I get the following error:

error: syntax error at or near "$2"

Also the following query is not working:

app.models.Histrollup.find({where: {property: inputs.property, staydate: {between: [inputs.startStaydate, inputs.endStaydate]}}, limit:10})

SQL: SELECT "property","staydate","rolluptype","totnights","totrevenue","bymarketcd","bychannel","byroomtype" FROM "castle"."v_histrollup" WHERE "property"=$1 AND "staydate" BETWEEN $2 AND $3 ORDER BY "property" LIMIT 10
Parameters: ["c5ba1990-c458-11e4-a8e5-0b887e7b0d20",{"sql":"to_timestamp(?,'yyyy-mm-dd hh24:mi:ss.ms')","params":["2014-04-28T10:00:00.000Z"]},{"sql":"to_timestamp(?,'yyyy-mm-dd hh24:mi:ss.ms')","params":["2014-10-01T09:59:59.999Z"]}]

error: invalid input syntax for type date: "{"sql":"to_timestamp(?,'yyyy-mm-dd hh24:mi:ss.ms')","params":["2014-04-28T10:00:00.000Z"]}"

Regards,
-Kesav

raymondfeng pushed a commit to loopbackio/loopback-connector that referenced this issue May 20, 2015
raymondfeng pushed a commit to loopbackio/loopback-connector that referenced this issue May 20, 2015
raymondfeng pushed a commit that referenced this issue May 20, 2015
@raymondfeng
Copy link
Contributor

Thank you for reporting the issue. It should be fixed now.

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

No branches or pull requests

2 participants