System.Data.SQLite
Artifact Content
Not logged in

Artifact 2a6ddbffcf71c6f1c6ca19c8ff65335adadd84d6:


###############################################################################
#
# tkt-3c00ec5b52.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-3c00ec5b52-1.1 {default types, via connection} -setup {
  setupDb [set fileName tkt-3c00ec5b52-1.1.db] "" "" "" UseConnectionTypes \
      "DefaultDbType=String;DefaultTypeName=TEXT;"
} -body {
  set connection [getDbConnection]
  set result [list]

  lappend result [object invoke -flags +NonPublic \
      System.Data.SQLite.SQLiteConvert TypeNameToDbType $connection "" None]

  lappend result [object invoke -flags +NonPublic \
      System.Data.SQLite.SQLiteConvert DbTypeToTypeName $connection Object None]

  set result
} -cleanup {
  freeDbConnection

  unset -nocomplain result connection

  cleanupDb $fileName

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

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

runTest {test tkt-3c00ec5b52-1.2 {fallback default types w/flag} -setup {
  setupDb [set fileName tkt-3c00ec5b52-1.2.db] "" "" "" UseConnectionTypes
} -body {
  set connection [getDbConnection]
  set result [list]

  lappend result [object invoke -flags +NonPublic \
      System.Data.SQLite.SQLiteConvert TypeNameToDbType $connection "" None]

  lappend result [object invoke -flags +NonPublic \
      System.Data.SQLite.SQLiteConvert DbTypeToTypeName $connection Object None]

  set result
} -cleanup {
  freeDbConnection

  unset -nocomplain result connection

  cleanupDb $fileName

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

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

runTest {test tkt-3c00ec5b52-1.3 {fallback default types w/o flag} -setup {
  setupDb [set fileName tkt-3c00ec5b52-1.3.db]
} -body {
  set connection [getDbConnection]
  set result [list]

  lappend result [object invoke -flags +NonPublic \
      System.Data.SQLite.SQLiteConvert TypeNameToDbType $connection "" None]

  lappend result [object invoke -flags +NonPublic \
      System.Data.SQLite.SQLiteConvert DbTypeToTypeName $connection Object None]

  set result
} -cleanup {
  freeDbConnection

  unset -nocomplain result connection

  cleanupDb $fileName

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

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

runTest {test tkt-3c00ec5b52-1.4 {default types, via environment} -setup {
  saveSQLiteConvertEnvironment

  set env(Use_SQLiteConvert_DefaultDbType) String
  set env(Use_SQLiteConvert_DefaultTypeName) TEXT

  setupDb [set fileName tkt-3c00ec5b52-1.4.db]
} -body {
  set connection [getDbConnection]
  set result [list]

  lappend result [object invoke -flags +NonPublic \
      System.Data.SQLite.SQLiteConvert TypeNameToDbType $connection "" None]

  lappend result [object invoke -flags +NonPublic \
      System.Data.SQLite.SQLiteConvert DbTypeToTypeName $connection Object None]

  set result
} -cleanup {
  freeDbConnection

  unset -nocomplain result connection

  cleanupDb $fileName
  restoreSQLiteConvertEnvironment

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

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

runTest {test tkt-3c00ec5b52-1.5 {default types, with unique index} -setup {
  saveSQLiteConvertEnvironment

  set env(Use_SQLiteConvert_DefaultDbType) String
  set env(Use_SQLiteConvert_DefaultTypeName) TEXT

  setupDb [set fileName tkt-3c00ec5b52-1.5.db]
} -body {
  sql execute $db "CREATE TABLE t1(x UNIQUE);"

  set connection [getDbConnection]
  set dataTable [$connection -alias GetSchema INDEXES]
  set results [list]

  object foreach -alias dataRow [set dataRows [$dataTable -alias Rows]] {
    lappend results [list [$dataRow Item TABLE_NAME] \
        [$dataRow Item INDEX_NAME] [$dataRow Item UNIQUE]]
  }

  set results
} -cleanup {
  freeDbConnection

  unset -nocomplain results dataRow dataRows dataTable connection

  cleanupDb $fileName
  restoreSQLiteConvertEnvironment

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

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

runSQLiteTestEpilogue
runTestEpilogue