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.

0.1.alpha-32 invalid syntax for integer. .findBy new functionality error with relations

See original GitHub issue

.find* methods now have keyof for entity for fields, but passing relation entity fully gives db-level error. Passing id (as it worked in 0.0.11 version of typeorm) gives typescript compiler error that it’s supposed to be entity but not integer.

working:

0.0.11

await em.findOne(Post, {
  user: user.id,
  productName
});

but 0.1.alpha-32 same code does not compile, since find options are now keyof Entity

If I pass whole entity db dies with “invalid syntax integer” since it tries to use whole object in select.

Maybe I did not catch up with new functionality of some kind?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
pleerockcommented, Jul 27, 2017

no, not finding by relation. I told you to add a new column called userId, like this:

@Column({ nullable: true })
userId: number;

and relation will use this column (and create FK for this). It will work since their names match. Plus you can use it in findOptions

0reactions
idchlifecommented, Jul 27, 2017

@pleerock I actually thought it is designed and going to stay - column name as entity name without id postfixed and in database as key.

0.0.11 version image

About your suggestion - this is interesting approach, but will 0.1 version support

await em.findOne(Post, {
  user: user,
  productName
})

?

Right now typeorm does not convert user entity object to it’s id so sql will be valid.

Wait a minute. I misread your post. You mean findBy is not actually supposed to work with relations, yes? Finding by relations.

Read more comments on GitHub >

github_iconTop Results From Across the Web

PG COPY error: invalid input syntax for integer - Stack Overflow
ERROR : invalid input syntax for integer: "". "" isn't a valid integer. PostgreSQL accepts unquoted blank fields as null by default in...
Read more >
Search an integer array fails, invalid syntax for integer #2495
I am referencing JSON / Array issue #442 RN - 65 Node - 14 Express - 4.1 I have a very simple PG...
Read more >
Re: ERROR: invalid input syntax for integer - PostgreSQL
If a geometry is NULL, the st_distance_sphere postgis function returned NULL. NULL/1000 = NULL. round(NULL) = NULL. AND NULL < 150 = NULL....
Read more >
InvalidTextRepresentation: invalid input syntax for integer
While doing a GET operation on /query , Trac issued an internal error. We have a custom field duedate: [ticket-custom] duedate = time...
Read more >
7 ERROR: invalid input syntax for integer - Laracasts
Problem with postgresql 'where' function SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for integer: A simple query. Copy Code
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