System.Data.SQLite

Artifact [61e427023a]
Login

Artifact 61e427023a1baad50a327ea3f5c5dfa6c7293066:


###############################################################################
#
# tkt-b167206ad3.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-b167206ad3-1.1 {type affinity for DECIMAL} -setup {
  setupDb [set fileName tkt-b167206ad3-1.1.db]
} -body {
  sql execute $db {
    CREATE TABLE t1(x INTEGER, y DECIMAL(38,9));
    INSERT INTO t1 (x, y) VALUES(1, 123456789123456780);
    INSERT INTO t1 (x, y) VALUES(2, '123456789123456780');
  }

  set dataReader [sql execute -execute reader -format datareader \
      -alias $db "SELECT x, y FROM t1 ORDER BY x;"]

  set result [list]

  while {[$dataReader Read]} {
    set x [$dataReader -create -alias GetValue 0]
    set y1 [$dataReader -create -alias GetDecimal 1]
    set y2 [$dataReader -create -alias GetValue 1]

    lappend result [list [$x ToString] [$y1 ToString] [$y2 ToString]]
  }

  set result
} -cleanup {
  unset -nocomplain dataReader

  cleanupDb $fileName

  unset -nocomplain y2 y1 x result db fileName
} -constraints {eagle command.object monoBug28 command.sql compile.DATA SQLite\
System.Data.SQLite} -result {{1 123456789123456780 123456789123457000} {2\
123456789123456780 123456789123457000}}}

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

runTest {test tkt-b167206ad3-1.2 {type affinity for DECIMAL} -setup {
  setupDb [set fileName tkt-b167206ad3-1.2.db] "" "" "" GetDecimalAsText
} -body {
  sql execute $db {
    CREATE TABLE t1(x INTEGER, y DECIMAL(38,9));
    INSERT INTO t1 (x, y) VALUES(1, 123456789123456780);
    INSERT INTO t1 (x, y) VALUES(2, '123456789123456780');
  }

  set dataReader [sql execute -execute reader -format datareader \
      -alias $db "SELECT x, y FROM t1 ORDER BY x;"]

  set result [list]

  while {[$dataReader Read]} {
    set x [$dataReader -create -alias GetValue 0]
    set y1 [$dataReader -create -alias GetDecimal 1]
    set y2 [$dataReader -create -alias GetValue 1]

    lappend result [list [$x ToString] [$y1 ToString] [$y2 ToString]]
  }

  set result
} -cleanup {
  unset -nocomplain dataReader

  cleanupDb $fileName

  unset -nocomplain y2 y1 x result db fileName
} -constraints {eagle command.object monoBug28 command.sql compile.DATA SQLite\
System.Data.SQLite} -result {{1 123456789123456780 123456789123456780} {2\
123456789123456780 123456789123456780}}}

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

runTest {test tkt-b167206ad3-1.3 {type affinity for NUMERIC} -setup {
  setupDb [set fileName tkt-b167206ad3-1.3.db]
} -body {
  sql execute $db {
    CREATE TABLE t1(x INTEGER, y NUMERIC);
    INSERT INTO t1 (x, y) VALUES(1, 123456789123456780);
    INSERT INTO t1 (x, y) VALUES(2, '123456789123456780');
  }

  set dataReader [sql execute -execute reader -format datareader \
      -alias $db "SELECT x, y FROM t1 ORDER BY x;"]

  set result [list]

  while {[$dataReader Read]} {
    set x [$dataReader -create -alias GetValue 0]
    set y1 [$dataReader -create -alias GetDecimal 1]
    set y2 [$dataReader -create -alias GetValue 1]

    lappend result [list [$x ToString] [$y1 ToString] [$y2 ToString]]
  }

  set result
} -cleanup {
  unset -nocomplain dataReader

  cleanupDb $fileName

  unset -nocomplain y2 y1 x result db fileName
} -constraints {eagle command.object monoBug28 command.sql compile.DATA SQLite\
System.Data.SQLite} -result {{1 123456789123456780 123456789123457000} {2\
123456789123456780 123456789123457000}}}

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

runTest {test tkt-b167206ad3-1.4 {type affinity for NUMERIC} -setup {
  setupDb [set fileName tkt-b167206ad3-1.4.db] "" "" "" GetDecimalAsText
} -body {
  sql execute $db {
    CREATE TABLE t1(x INTEGER, y NUMERIC);
    INSERT INTO t1 (x, y) VALUES(1, 123456789123456780);
    INSERT INTO t1 (x, y) VALUES(2, '123456789123456780');
  }

  set dataReader [sql execute -execute reader -format datareader \
      -alias $db "SELECT x, y FROM t1 ORDER BY x;"]

  set result [list]

  while {[$dataReader Read]} {
    set x [$dataReader -create -alias GetValue 0]
    set y1 [$dataReader -create -alias GetDecimal 1]
    set y2 [$dataReader -create -alias GetValue 1]

    lappend result [list [$x ToString] [$y1 ToString] [$y2 ToString]]
  }

  set result
} -cleanup {
  unset -nocomplain dataReader

  cleanupDb $fileName

  unset -nocomplain y2 y1 x result db fileName
} -constraints {eagle command.object monoBug28 command.sql compile.DATA SQLite\
System.Data.SQLite} -result {{1 123456789123456780 123456789123456780} {2\
123456789123456780 123456789123456780}}}

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

runSQLiteTestEpilogue
runTestEpilogue