question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

LessThan and other operators doesn't work

See original GitHub issue

Issue type:

[ ] question [x] bug report [ ] feature request [ ] documentation issue

Database system/driver:

[ ] cordova [ ] mongodb [ ] mssql [ ] mysql / mariadb [ ] oracle [x] postgres [ ] cockroachdb [ ] sqlite [ ] sqljs [ ] react-native [ ] expo

TypeORM version:

[x] latest [ ] @next [ ] 0.x.x (or put your version here)

Steps to reproduce or a small repository showing the problem:

I’m using typeorm inside js and it seems like the query parsed incorrectly, here is my example:

const entities = await Entity.count({
      where: {
        name: 'entityName',
        updatedAt: LessThan(new Date()),
      },
    });

And here is the sql output:

SELECT COUNT(DISTINCT("Entity"."id")) as "cnt" FROM "entities" "Entity" WHERE "Entity"."name" = $1 AND "Entity"."updatedAt" = $2 AND "Entity"."deletedAt" IS NULL -- PARAMETERS: ["entityName",{"_type":"lessThan","_value":"2019-04-08T12:11:05.602Z","_useParameter":true,"_multipleParameters":false}]

It’s working great within Nest.js framework but doesn’t work inside a pure node.js file.

Another thing to mention - Methods works just fine like: Entity.find() Entity.count() etc … So I don’t think it’s something with the db connection

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:11
  • Comments:18 (4 by maintainers)

github_iconTop GitHub Comments

8reactions
pkuczynskicommented, Apr 24, 2019

I am experiencing the same problem with postgres:

await XXX.findOne({ id: Not(Equal(x.id)), name: x.name }))

Produces an error:

QueryFailedError: invalid input syntax for integer: "{"type":"not","_useParameter":true,"_multipleParameters":false,"_value":{"type":"equal","_useParameter":true,"_multipleParameters":false,"_value":1}}"
7reactions
yogevlahyanicommented, Apr 21, 2019

@Kononnable I logged the SQL query and it seems that LessThan stays an object, for example:

where: {
  updatedAt: LessThan(new Date()),
}

Will be:

UPDATE ... updatedAt = { _value: .. ...... }

instead

UPDATE ... updatedAt < new Date()

It seems that it didn’t work as a local npm installed package but when I deployed it and installed the package from github, it worked.

I believe it is something about the shared typeorm package and the connection itself, but it did worked partly in the local way…

Read more comments on GitHub >

github_iconTop Results From Across the Web

OR and less than operators not working as intended C language
If either a or b is non-zero, then the expression is true. In C, equality and relational operators like == , !=
Read more >
Less than (<) - JavaScript - MDN Web Docs
The less than ( < ) operator returns true if the left operand is less than the right operand, and false otherwise.
Read more >
Logical operators in Excel: equal to, not equal to, greater than ...
The tutorial explains the basics of Excel logical operators such as equal to, not equal to, greater than or equal to, less than...
Read more >
13 Functions and expressions - Stata
The relational operators are > (greater than), < (less than), >= (greater than or equal), <= (less than or equal), == (equal), and...
Read more >
Comparison and Logical Operators - Codecademy
Comparison Operators · Less than ( < ) — returns true if the value on the left is less than the value on...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found