System.Data.SQLite

Artifact [ecd2823cfc]
Login

Artifact ecd2823cfc932ef7c8c27f102f711d907ce88605:


###############################################################################
#
# tkt-e06c4caff3.eagle --
#
# Written by Joe Mistachkin.
# Released to the public domain, use at your own risk!
#
###############################################################################

package require Eagle
package require Eagle.Library
package require Eagle.Test

runTestPrologue

###############################################################################

package require System.Data.SQLite.Test
runSQLiteTestPrologue

###############################################################################

runTest {test tkt-e06c4caff3-1.1 {NaN to NULL constraint failure} -setup {
  setupDb [set fileName tkt-e06c4caff3-1.1.db]
} -body {
  sql execute $db "CREATE TABLE t1(x REAL NOT NULL);"

  list [catch {
    sql execute $db "INSERT INTO t1 (x) VALUES(?);" \
        [list param1 Double [set NaN [object invoke Double NaN]]]
  } error] [extractSystemDataSQLiteExceptionMessage $error]
} -cleanup {
  cleanupDb $fileName

  unset -nocomplain NaN error db fileName
} -constraints {eagle command.object monoBug40 command.sql compile.DATA SQLite\
System.Data.SQLite} -result \
{1 {constraint failed -- NOT NULL constraint failed: t1.x}}}

###############################################################################

runTest {test tkt-e06c4caff3-1.2 {NaN to NULL} -setup {
  setupDb [set fileName tkt-e06c4caff3-1.2.db]
} -body {
  sql execute $db "CREATE TABLE t1(x REAL);"

  sql execute $db "INSERT INTO t1 (x) VALUES(?);" \
      [list param1 Double [set NaN [object invoke Double NaN]]]

  sql execute -execute reader -format list $db "SELECT x FROM t1;"
} -cleanup {
  cleanupDb $fileName

  unset -nocomplain NaN db fileName
} -constraints {eagle command.object monoBug28 command.sql compile.DATA SQLite\
System.Data.SQLite} -result {}}

###############################################################################

runTest {test tkt-e06c4caff3-1.3 {NaN w/BindAllAsText} -setup {
  setupDb [set fileName tkt-e06c4caff3-1.3.db] "" "" "" BindAllAsText
} -body {
  sql execute $db "CREATE TABLE t1(x REAL NOT NULL);"

  list [sql execute $db "INSERT INTO t1 (x) VALUES(?);" \
      [list param1 Double [set NaN [object invoke Double NaN]]]] \
      [sql execute -execute reader -format list $db "SELECT x FROM t1;"]
} -cleanup {
  cleanupDb $fileName

  unset -nocomplain NaN db fileName
} -constraints {eagle command.object monoBug28 command.sql compile.DATA SQLite\
System.Data.SQLite} -result {1 0}}

###############################################################################

runTest {test tkt-e06c4caff3-1.4 {NaN w/BindAllAsText & GetAllAsText} -setup {
  setupDb [set fileName tkt-e06c4caff3-1.4.db] "" "" "" BindAndGetAllAsText
} -body {
  sql execute $db "CREATE TABLE t1(x REAL NOT NULL);"

  list [sql execute $db "INSERT INTO t1 (x) VALUES(?);" \
      [list param1 Double [set NaN [object invoke Double NaN]]]] \
      [sql execute -execute reader -format list $db "SELECT x FROM t1;"]
} -cleanup {
  cleanupDb $fileName

  unset -nocomplain NaN db fileName
} -constraints {eagle command.object monoBug28 command.sql compile.DATA SQLite\
System.Data.SQLite} -result {1 NaN}}

###############################################################################

runSQLiteTestEpilogue
runTestEpilogue