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.

SQLite sql generation issue?

See original GitHub issue

I have this query _dataConnection.GetTable<TEntity>().Single(x => x.MyColumn == "xYz") which generates a wrong sql

--  SQLite.Classic SQLite
DECLARE @take  -- Int32
SET     @take = 2

SELECT
	[x].[Id],
	[x].[MyColumn]
FROM
	[TableName] [x]
WHERE
	[x].[MyColumn] = 'xYz'
LIMIT @take

Exception message: Sequence contains no elements Exception thrown: ‘System.InvalidOperationException’ in System.Linq.dll Exception thrown: ‘System.InvalidOperationException’ in System.Private.CoreLib.dll

Environment details

linq2db version: 3.1.6 Database Provider: SQLite Operating system: Windows 10 Pro for Workstations .NET Framework: .NET Core 3.1

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
MaceWinducommented, Dec 10, 2020

If you need case-sensitive comparison, you can define custom comparison function:

[Sql.Expression("{0} COLLATE RTRIM = {1}", ServerSideOnly = true)]
public static bool Compare(string left, string right) => left == right;

or BINARY instead of RTRIM (sqlite doesn’t have a lot of collations: https://www.sqlite.org/datatype3.html#collation)

Read more comments on GitHub >

github_iconTop Results From Across the Web

CG/SQL: Easy, accurate code generation for SQLite
The generated code always checks the various return codes and always uses the correct column ordinals and column types when binding or reading ......
Read more >
objective c - sqlite db creation issue
Im running a method which checks if DB exists, if not, it creates the db. Ive found several examples where different paths are...
Read more >
Result and Error Codes
The SQLITE_OK result code means that the operation was successful and that there were no errors. Most other result codes indicate an error....
Read more >
The Next-Generation Query Planner
The QPSG means that if all of your queries run efficiently during testing, and if your application does not change the schema, then...
Read more >
Frequently Asked Questions
Unless opened with flags to prevent it, a SQLite database is created if it does not already exist. Newly created databases are initially...
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