Skip to content

Commit 1a527c0

Browse files
Add bitwise xor support to SQLite
Fixes #1690
1 parent 3aa348d commit 1a527c0

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

src/NHibernate.Test/TestCase.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -447,14 +447,6 @@ protected DateTime RoundForDialect(DateTime value)
447447
{"locate", new HashSet<System.Type> {typeof (SQLiteDialect)}},
448448
{"bit_length", new HashSet<System.Type> {typeof (SQLiteDialect)}},
449449
{"extract", new HashSet<System.Type> {typeof (SQLiteDialect)}},
450-
{
451-
"bxor",
452-
new HashSet<System.Type>
453-
{
454-
// Could be supported like Oracle, with a template
455-
typeof (SQLiteDialect)
456-
}
457-
},
458450
{
459451
"nullif",
460452
new HashSet<System.Type>

src/NHibernate/Dialect/SQLiteDialect.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ protected virtual void RegisterFunctions()
8888

8989
RegisterFunction("round", new StandardSQLFunction("round"));
9090

91+
// SQLite has no built-in support of bitwise xor, but can emulate it.
92+
// http://sqlite.1065341.n5.nabble.com/XOR-operator-td98004.html
93+
RegisterFunction("bxor", new SQLFunctionTemplate(null, "((?1 | ?2) - (?1 & ?2))"));
94+
9195
// NH-3787: SQLite requires the cast in SQL too for not defaulting to string.
9296
RegisterFunction("transparentcast", new CastFunction());
9397
}

0 commit comments

Comments
 (0)