summaryrefslogtreecommitdiff
path: root/tests/unit/Data
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/Data')
-rw-r--r--tests/unit/Data/ActiveRecord/ActiveRecordDynamicCallTest.php70
-rw-r--r--tests/unit/Data/ActiveRecord/ActiveRecordFinderTest.php46
-rw-r--r--tests/unit/Data/ActiveRecord/ActiveRecordMySql5Test.php48
-rw-r--r--tests/unit/Data/ActiveRecord/BaseActiveRecordTest.php34
-rw-r--r--tests/unit/Data/ActiveRecord/CountRecordsTest.php36
-rw-r--r--tests/unit/Data/ActiveRecord/CriteriaTest.php51
-rw-r--r--tests/unit/Data/ActiveRecord/DeleteByPkTest.php33
-rw-r--r--tests/unit/Data/ActiveRecord/FindByPksTest.php65
-rw-r--r--tests/unit/Data/ActiveRecord/FindBySqlTest.php47
-rw-r--r--tests/unit/Data/ActiveRecord/ForeignKeyTest.php176
-rw-r--r--tests/unit/Data/ActiveRecord/ForeignObjectUpdateTest.php243
-rw-r--r--tests/unit/Data/ActiveRecord/MultipleForeignKeyTest.php193
-rw-r--r--tests/unit/Data/ActiveRecord/RecordEventTest.php38
-rw-r--r--tests/unit/Data/ActiveRecord/SqliteTest.php22
-rw-r--r--tests/unit/Data/ActiveRecord/UserRecordTest.php67
-rw-r--r--tests/unit/Data/ActiveRecord/ViewRecordTest.php78
-rw-r--r--tests/unit/Data/ActiveRecord/ar_test.dbbin0 -> 5120 bytes
-rw-r--r--tests/unit/Data/ActiveRecord/blog.dbbin0 -> 4096 bytes
-rw-r--r--tests/unit/Data/ActiveRecord/fk_tests.dbbin0 -> 9216 bytes
-rw-r--r--tests/unit/Data/ActiveRecord/mysql4text.sql52
-rw-r--r--tests/unit/Data/ActiveRecord/records/Blogs.php12
-rw-r--r--tests/unit/Data/ActiveRecord/records/DepSections.php14
-rw-r--r--tests/unit/Data/ActiveRecord/records/DepartmentRecord.php16
-rw-r--r--tests/unit/Data/ActiveRecord/records/ItemRecord.php47
-rw-r--r--tests/unit/Data/ActiveRecord/records/SimpleUser.php12
-rw-r--r--tests/unit/Data/ActiveRecord/records/SqliteUsers.php14
-rw-r--r--tests/unit/Data/ActiveRecord/records/UserRecord.php36
-rw-r--r--tests/unit/Data/ActiveRecord/sqlite.sql46
-rw-r--r--tests/unit/Data/ActiveRecord/test1.sqlitebin0 -> 6144 bytes
-rw-r--r--tests/unit/Data/DataGateway/AllTests.php27
-rw-r--r--tests/unit/Data/DbCommon/CommandBuilderMssqlTest.php47
-rw-r--r--tests/unit/Data/DbCommon/CommandBuilderMysqlTest.php20
-rw-r--r--tests/unit/Data/DbCommon/CommandBuilderPgsqlTest.php77
-rw-r--r--tests/unit/Data/DbCommon/MssqlColumnTest.php49
-rw-r--r--tests/unit/Data/DbCommon/Mysql4ColumnTest.php255
-rw-r--r--tests/unit/Data/DbCommon/MysqlColumnTest.php255
-rw-r--r--tests/unit/Data/DbCommon/PgsqlColumnTest.php141
-rw-r--r--tests/unit/Data/DbCommon/SqliteColumnTest.php32
-rw-r--r--tests/unit/Data/SqlMap/ActiveRecordSqlMapTest.php88
-rw-r--r--tests/unit/Data/SqlMap/AllTests.php29
-rw-r--r--tests/unit/Data/SqlMap/BaseCase.php260
-rw-r--r--tests/unit/Data/SqlMap/CacheTest.php162
-rw-r--r--tests/unit/Data/SqlMap/DataMapper/AllTests.php27
-rw-r--r--tests/unit/Data/SqlMap/DelegateTest.php62
-rw-r--r--tests/unit/Data/SqlMap/GroupByTest.php41
-rw-r--r--tests/unit/Data/SqlMap/InheritanceTest.php144
-rw-r--r--tests/unit/Data/SqlMap/ParameterMapTest.php247
-rw-r--r--tests/unit/Data/SqlMap/PropertyAccessTest.php75
-rw-r--r--tests/unit/Data/SqlMap/ResultClassTest.php247
-rw-r--r--tests/unit/Data/SqlMap/ResultMapTest.php271
-rw-r--r--tests/unit/Data/SqlMap/SelectKeyTest.php118
-rw-r--r--tests/unit/Data/SqlMap/SqlMapCacheTest.php75
-rw-r--r--tests/unit/Data/SqlMap/StatementExtendsTest.php31
-rw-r--r--tests/unit/Data/SqlMap/StatementTest.php1133
-rw-r--r--tests/unit/Data/SqlMap/TestQueryForMap.php44
-rw-r--r--tests/unit/Data/SqlMap/Ticket589Test.php23
-rw-r--r--tests/unit/Data/SqlMap/common.php153
-rw-r--r--tests/unit/Data/SqlMap/domain/A.php25
-rw-r--r--tests/unit/Data/SqlMap/domain/Account.php34
-rw-r--r--tests/unit/Data/SqlMap/domain/AccountBis.php11
-rw-r--r--tests/unit/Data/SqlMap/domain/AccountCollection.php15
-rw-r--r--tests/unit/Data/SqlMap/domain/B.php21
-rw-r--r--tests/unit/Data/SqlMap/domain/Book.php9
-rw-r--r--tests/unit/Data/SqlMap/domain/C.php13
-rw-r--r--tests/unit/Data/SqlMap/domain/Category.php17
-rw-r--r--tests/unit/Data/SqlMap/domain/Complex.php9
-rw-r--r--tests/unit/Data/SqlMap/domain/D.php14
-rw-r--r--tests/unit/Data/SqlMap/domain/Document.php14
-rw-r--r--tests/unit/Data/SqlMap/domain/DocumentCollection.php6
-rw-r--r--tests/unit/Data/SqlMap/domain/E.php14
-rw-r--r--tests/unit/Data/SqlMap/domain/F.php14
-rw-r--r--tests/unit/Data/SqlMap/domain/LineItem.php30
-rw-r--r--tests/unit/Data/SqlMap/domain/LineItemCollection.php6
-rw-r--r--tests/unit/Data/SqlMap/domain/Newspaper.php10
-rw-r--r--tests/unit/Data/SqlMap/domain/Order.php69
-rw-r--r--tests/unit/Data/SqlMap/domain/Other.php21
-rw-r--r--tests/unit/Data/SqlMap/domain/Sample.php53
-rw-r--r--tests/unit/Data/SqlMap/domain/Search.php21
-rw-r--r--tests/unit/Data/SqlMap/domain/User.php25
-rw-r--r--tests/unit/Data/SqlMap/gen.php31
-rw-r--r--tests/unit/Data/SqlMap/maps/MySql/Account.xml624
-rw-r--r--tests/unit/Data/SqlMap/maps/MySql/ActiveRecord.xml16
-rw-r--r--tests/unit/Data/SqlMap/maps/MySql/Category.xml162
-rw-r--r--tests/unit/Data/SqlMap/maps/MySql/Complex.xml23
-rw-r--r--tests/unit/Data/SqlMap/maps/MySql/Document.xml53
-rw-r--r--tests/unit/Data/SqlMap/maps/MySql/DynamicAccount.xml449
-rw-r--r--tests/unit/Data/SqlMap/maps/MySql/Enumeration.xml59
-rw-r--r--tests/unit/Data/SqlMap/maps/MySql/LineItem.xml188
-rw-r--r--tests/unit/Data/SqlMap/maps/MySql/Order.xml468
-rw-r--r--tests/unit/Data/SqlMap/maps/MySql/Other.xml170
-rw-r--r--tests/unit/Data/SqlMap/maps/MySql/ResultClass.xml130
-rw-r--r--tests/unit/Data/SqlMap/maps/mssql/Account.xml606
-rw-r--r--tests/unit/Data/SqlMap/maps/mssql/Category.xml171
-rw-r--r--tests/unit/Data/SqlMap/maps/mssql/Complex.xml21
-rw-r--r--tests/unit/Data/SqlMap/maps/mssql/Document.xml53
-rw-r--r--tests/unit/Data/SqlMap/maps/mssql/DynamicAccount.xml438
-rw-r--r--tests/unit/Data/SqlMap/maps/mssql/Enumeration.xml47
-rw-r--r--tests/unit/Data/SqlMap/maps/mssql/LineItem.xml182
-rw-r--r--tests/unit/Data/SqlMap/maps/mssql/Order.xml475
-rw-r--r--tests/unit/Data/SqlMap/maps/mssql/Other.xml171
-rw-r--r--tests/unit/Data/SqlMap/maps/mssql/ResultClass.xml125
-rw-r--r--tests/unit/Data/SqlMap/maps/sqlite/Account.xml641
-rw-r--r--tests/unit/Data/SqlMap/maps/sqlite/ActiveRecord.xml16
-rw-r--r--tests/unit/Data/SqlMap/maps/sqlite/Category.xml162
-rw-r--r--tests/unit/Data/SqlMap/maps/sqlite/Complex.xml23
-rw-r--r--tests/unit/Data/SqlMap/maps/sqlite/Document.xml53
-rw-r--r--tests/unit/Data/SqlMap/maps/sqlite/DynamicAccount.xml447
-rw-r--r--tests/unit/Data/SqlMap/maps/sqlite/Enumeration.xml55
-rw-r--r--tests/unit/Data/SqlMap/maps/sqlite/LineItem.xml183
-rw-r--r--tests/unit/Data/SqlMap/maps/sqlite/Order.xml503
-rw-r--r--tests/unit/Data/SqlMap/maps/sqlite/Other.xml170
-rw-r--r--tests/unit/Data/SqlMap/maps/sqlite/ResultClass.xml130
-rw-r--r--tests/unit/Data/SqlMap/maps/tests.xml19
-rw-r--r--tests/unit/Data/SqlMap/mssql.xml33
-rw-r--r--tests/unit/Data/SqlMap/mysql.xml29
-rw-r--r--tests/unit/Data/SqlMap/properties.config8
-rw-r--r--tests/unit/Data/SqlMap/queryForListLimitTest.php38
-rw-r--r--tests/unit/Data/SqlMap/resources/data.dbbin0 -> 5120 bytes
-rw-r--r--tests/unit/Data/SqlMap/resources/person.xml26
-rw-r--r--tests/unit/Data/SqlMap/resources/sqlmap.xml12
-rw-r--r--tests/unit/Data/SqlMap/resources/test.dbbin0 -> 5120 bytes
-rw-r--r--tests/unit/Data/SqlMap/resources/tests.db0
-rw-r--r--tests/unit/Data/SqlMap/scripts/mssql/DBCreation.sql89
-rw-r--r--tests/unit/Data/SqlMap/scripts/mssql/DataBase.sql179
-rw-r--r--tests/unit/Data/SqlMap/scripts/mssql/README-embed-param.txt8
-rw-r--r--tests/unit/Data/SqlMap/scripts/mssql/account-init.sql47
-rw-r--r--tests/unit/Data/SqlMap/scripts/mssql/account-procedure.sql12
-rw-r--r--tests/unit/Data/SqlMap/scripts/mssql/category-init.sql17
-rw-r--r--tests/unit/Data/SqlMap/scripts/mssql/category-procedure.sql10
-rw-r--r--tests/unit/Data/SqlMap/scripts/mssql/documents-init.sql34
-rw-r--r--tests/unit/Data/SqlMap/scripts/mssql/embed-param-setup-init.sql94
-rw-r--r--tests/unit/Data/SqlMap/scripts/mssql/embed-param-test-init.sql32
-rw-r--r--tests/unit/Data/SqlMap/scripts/mssql/enumeration-init.sql30
-rw-r--r--tests/unit/Data/SqlMap/scripts/mssql/line-item-init.sql53
-rw-r--r--tests/unit/Data/SqlMap/scripts/mssql/more-account-records.sql11
-rw-r--r--tests/unit/Data/SqlMap/scripts/mssql/order-init.sql54
-rw-r--r--tests/unit/Data/SqlMap/scripts/mssql/other-init.sql145
-rw-r--r--tests/unit/Data/SqlMap/scripts/mssql/ps_SelectAccount.sql10
-rw-r--r--tests/unit/Data/SqlMap/scripts/mssql/swap-procedure.sql34
-rw-r--r--tests/unit/Data/SqlMap/scripts/mssql/user-init.sql17
-rw-r--r--tests/unit/Data/SqlMap/scripts/mysql/DataBase.sql356
-rw-r--r--tests/unit/Data/SqlMap/scripts/mysql/account-init.sql7
-rw-r--r--tests/unit/Data/SqlMap/scripts/mysql/account-procedure.sql1
-rw-r--r--tests/unit/Data/SqlMap/scripts/mysql/category-init.sql1
-rw-r--r--tests/unit/Data/SqlMap/scripts/mysql/category-procedure.sql0
-rw-r--r--tests/unit/Data/SqlMap/scripts/mysql/documents-init.sql8
-rw-r--r--tests/unit/Data/SqlMap/scripts/mysql/enumeration-init.sql6
-rw-r--r--tests/unit/Data/SqlMap/scripts/mysql/line-item-init.sql24
-rw-r--r--tests/unit/Data/SqlMap/scripts/mysql/more-account-records.sql7
-rw-r--r--tests/unit/Data/SqlMap/scripts/mysql/order-init.sql15
-rw-r--r--tests/unit/Data/SqlMap/scripts/mysql/other-init.sql18
-rw-r--r--tests/unit/Data/SqlMap/scripts/mysql/swap-procedure.sql0
-rw-r--r--tests/unit/Data/SqlMap/scripts/mysql/user-init.sql2
-rw-r--r--tests/unit/Data/SqlMap/scripts/sqlite/database.sql242
-rw-r--r--tests/unit/Data/SqlMap/sqlite.xml31
-rw-r--r--tests/unit/Data/SqlMap/sqlite/backup.dbbin0 -> 24576 bytes
-rw-r--r--tests/unit/Data/SqlMap/sqlite/tests.dbbin0 -> 24576 bytes
-rw-r--r--tests/unit/Data/SqlMap/sqlmap.xml21
-rw-r--r--tests/unit/Data/TableGateway/BaseGatewayTest.php96
-rw-r--r--tests/unit/Data/TableGateway/CountTest.php18
-rw-r--r--tests/unit/Data/TableGateway/MagicCallTest.php33
-rw-r--r--tests/unit/Data/TableGateway/TableGatewayDeleteByPkTest.php54
-rw-r--r--tests/unit/Data/TableGateway/TableGatewayPgsqlTest.php58
-rw-r--r--tests/unit/Data/TableGateway/TableInfoGatewayTest.php19
-rw-r--r--tests/unit/Data/TableGateway/TestFindByPk.php50
165 files changed, 15150 insertions, 83 deletions
diff --git a/tests/unit/Data/ActiveRecord/ActiveRecordDynamicCallTest.php b/tests/unit/Data/ActiveRecord/ActiveRecordDynamicCallTest.php
new file mode 100644
index 00000000..1bf98415
--- /dev/null
+++ b/tests/unit/Data/ActiveRecord/ActiveRecordDynamicCallTest.php
@@ -0,0 +1,70 @@
+<?php
+Prado::using('System.Data.ActiveRecord.TActiveRecord');
+require_once(dirname(__FILE__).'/records/DepartmentRecord.php');
+require_once(dirname(__FILE__).'/records/DepSections.php');
+
+/**
+ * @package System.Data.ActiveRecord
+ */
+class ActiveRecordDynamicCallTest extends PHPUnit_Framework_TestCase
+{
+ function setup()
+ {
+ $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test');
+ TActiveRecordManager::getInstance()->setDbConnection($conn);
+ }
+
+ function test_multiple_field_and_or()
+ {
+ $finder = DepartmentRecord::finder();
+ $r2 = $finder->findAllByName_And_Description_Or_Active_Or_Order('Facilities', null, false, 1);
+ $this->assertNotNull($r2);
+ }
+
+ function test_dynamic_call()
+ {
+ $finder = DepartmentRecord::finder();
+ $r2 = $finder->findByName('Facilities');
+ $this->assertNotNull($r2);
+ }
+
+ function test_dynamic_multiple_field_call()
+ {
+ $finder = DepartmentRecord::finder();
+ $rs = $finder->findByNameAndActive('Marketing',true);
+ $this->assertNotNull($rs);
+ }
+
+ function test_dynamic_call_missing_parameters_throws_exception()
+ {
+ $finder = DepartmentRecord::finder();
+ try
+ {
+ $rs = $finder->findByNameAndActive('Marketing');
+ $this->fail();
+ }
+ catch(TDbException $e)
+ {
+ $this->pass();
+ }
+ }
+
+ function test_dynamic_call_extras_parameters_ok()
+ {
+ $finder = DepartmentRecord::finder();
+ $rs = $finder->findByNameAndActive('Marketing',true,true);
+ $this->assertNotNull($rs);
+ }
+
+ function test_dynamic_delete_by()
+ {
+ $finder = DepartmentRecord::finder();
+ //$finder->RecordManager->OnDelete[] = array($this, 'assertDeleteSql');
+ $this->assertEqual($finder->deleteByName('tasds'), 0);
+ }
+
+ function assertDeleteSql($sender, $param)
+ {
+ var_dump($param);
+ }
+}
diff --git a/tests/unit/Data/ActiveRecord/ActiveRecordFinderTest.php b/tests/unit/Data/ActiveRecord/ActiveRecordFinderTest.php
new file mode 100644
index 00000000..2209fc6a
--- /dev/null
+++ b/tests/unit/Data/ActiveRecord/ActiveRecordFinderTest.php
@@ -0,0 +1,46 @@
+<?php
+Prado::using('System.Data.ActiveRecord.TActiveRecord');
+require_once(dirname(__FILE__).'/records/DepartmentRecord.php');
+
+/**
+ * @package System.Data.ActiveRecord
+ */
+class ActiveRecordFinderTest extends PHPUnit_Framework_TestCase
+{
+ function setup()
+ {
+ $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test');
+ TActiveRecordManager::getInstance()->setDbConnection($conn);
+ }
+
+ function testFindBySQL_returns_one_record()
+ {
+ $department = DepartmentRecord::finder()->find('department_id < ?', 5);
+ $this->assertNotNull($department);
+ }
+
+ function testFindBySQL_returns_zero_records()
+ {
+ $department = DepartmentRecord::finder()->find('department_id > ?', 15);
+ $this->assertNull($department);
+ }
+
+ function test_find_by_sql_returns_iterator()
+ {
+ $deps = DepartmentRecord::finder()->findAll('department_id < :id', array('id'=>5));
+ $this->assertEqual(count($deps),4);
+ }
+
+ function test_find_by_multiple_parameters()
+ {
+ $department = DepartmentRecord::finder()->find('department_id < ? AND "order" > ?', 5,2);
+ $this->assertNotNull($department);
+ }
+
+ function test_find_by_array_parameter()
+ {
+ $department = DepartmentRecord::finder()->find('department_id < ? AND "order" > ?', array(5,2));
+ $this->assertNotNull($department);
+ }
+
+}
diff --git a/tests/unit/Data/ActiveRecord/ActiveRecordMySql5Test.php b/tests/unit/Data/ActiveRecord/ActiveRecordMySql5Test.php
new file mode 100644
index 00000000..31cbed5c
--- /dev/null
+++ b/tests/unit/Data/ActiveRecord/ActiveRecordMySql5Test.php
@@ -0,0 +1,48 @@
+<?php
+Prado::using('System.Data.ActiveRecord.TActiveRecord');
+require_once(dirname(__FILE__).'/records/Blogs.php');
+
+/**
+ * @package System.Data.ActiveRecord
+ */
+class ActiveRecordMySql5Test extends PHPUnit_Framework_TestCase
+{
+ function setup()
+ {
+ $conn = new TDbConnection('mysql:host=localhost;dbname=ar_test;port=3307', 'test5','test5');
+ TActiveRecordManager::getInstance()->setDbConnection($conn);
+ }
+
+ function test_find_first_blog()
+ {
+ $blog = Blogs::finder()->findByPk(1);
+ $this->assertNotNull($blog);
+ }
+
+ function test_insert_new_blog()
+ {
+ $blog = new Blogs();
+ $blog->blog_name = 'test1';
+ $blog->blog_author = 'wei';
+
+ $this->assertTrue($blog->save());
+
+ $blog->blog_name = 'test2';
+
+ $this->assertTrue($blog->save());
+
+ $check = Blogs::finder()->findByPk($blog->blog_id);
+
+ $this->assertSameBlog($check,$blog);
+
+ $this->assertTrue($blog->delete());
+ }
+
+ function assertSameBlog($check, $blog)
+ {
+ $props = array('blog_id', 'blog_name', 'blog_author');
+ foreach($props as $prop)
+ $this->assertEqual($check->{$prop}, $blog->{$prop});
+ }
+
+} \ No newline at end of file
diff --git a/tests/unit/Data/ActiveRecord/BaseActiveRecordTest.php b/tests/unit/Data/ActiveRecord/BaseActiveRecordTest.php
new file mode 100644
index 00000000..258fe70c
--- /dev/null
+++ b/tests/unit/Data/ActiveRecord/BaseActiveRecordTest.php
@@ -0,0 +1,34 @@
+<?php
+Prado::using('System.Data.ActiveRecord.TActiveRecord');
+
+/**
+ * @package System.Data.ActiveRecord
+ */
+class BaseRecordTest extends TActiveRecord
+{
+
+}
+
+class BaseActiveRecordTest extends PHPUnit_Framework_TestCase
+{
+ function test_finder_returns_same_instance()
+ {
+ $obj1 = TActiveRecord::finder('BaseRecordTest');
+ $obj2 = TActiveRecord::finder('BaseRecordTest');
+ $this->assertIdentical($obj1,$obj2);
+ }
+
+ function test_finder_throw_exception_when_save()
+ {
+ $obj = TActiveRecord::finder('BaseRecordTest');
+ try
+ {
+ $obj->save();
+ $this->fail();
+ }
+ catch(TActiveRecordException $e)
+ {
+ $this->pass();
+ }
+ }
+}
diff --git a/tests/unit/Data/ActiveRecord/CountRecordsTest.php b/tests/unit/Data/ActiveRecord/CountRecordsTest.php
new file mode 100644
index 00000000..b97f83ed
--- /dev/null
+++ b/tests/unit/Data/ActiveRecord/CountRecordsTest.php
@@ -0,0 +1,36 @@
+<?php
+
+Prado::using('System.Data.ActiveRecord.TActiveRecord');
+require_once(dirname(__FILE__).'/records/DepartmentRecord.php');
+
+/**
+ * @package System.Data.ActiveRecord
+ */
+class CountRecordsTest extends PHPUnit_Framework_TestCase
+{
+ function setup()
+ {
+ $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test');
+ TActiveRecordManager::getInstance()->setDbConnection($conn);
+ }
+
+ function test_count()
+ {
+ $finder = DepartmentRecord::finder();
+ $count = $finder->count('"order" > ?', 2);
+ $this->assertTrue($count > 0);
+ }
+
+ function test_count_zero()
+ {
+ $finder = DepartmentRecord::finder();
+ $count = $finder->count('"order" > ?', 11);
+ $this->assertEqual($count,0);
+ }
+
+ function test_count_without_parameter()
+ {
+ $finder = DepartmentRecord::finder();
+ $this->assertEqual($finder->count(), 8);
+ }
+}
diff --git a/tests/unit/Data/ActiveRecord/CriteriaTest.php b/tests/unit/Data/ActiveRecord/CriteriaTest.php
new file mode 100644
index 00000000..3c4c15d7
--- /dev/null
+++ b/tests/unit/Data/ActiveRecord/CriteriaTest.php
@@ -0,0 +1,51 @@
+<?php
+
+Prado::using('System.Data.ActiveRecord.TActiveRecord');
+require_once(dirname(__FILE__).'/records/DepartmentRecord.php');
+require_once(dirname(__FILE__).'/records/DepSections.php');
+
+/**
+ * @package System.Data.ActiveRecord
+ */
+class CriteriaTest extends PHPUnit_Framework_TestCase
+{
+ function setup()
+ {
+ $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test');
+ TActiveRecordManager::getInstance()->setDbConnection($conn);
+ }
+
+ function test_orderby_only()
+ {
+ $criteria = new TActiveRecordCriteria;
+ $criteria->OrdersBy['name'] = 'asc';
+ $records = DepartmentRecord::finder()->findAll($criteria);
+ $this->assertEqual(count($records), 8);
+ $this->assertEqual($records[0]->name, '+GX Service');
+ $this->assertEqual($records[7]->name, 'Marketing');
+ }
+
+ function test_orderby_only_desc()
+ {
+ $criteria = new TActiveRecordCriteria;
+ $criteria->OrdersBy['name'] = 'desc';
+ $records = DepartmentRecord::finder()->findAll($criteria);
+ $this->assertEqual(count($records), 8);
+ $this->assertEqual($records[7]->name, '+GX Service');
+ $this->assertEqual($records[0]->name, 'Marketing');
+ }
+
+ function test_criteria_parameters()
+ {
+ $criteria = new TActiveRecordCriteria('sql', "One", "two", 3);
+ $expect = array("One", "two", 3);
+ $this->assertEqual($criteria->getParameters()->toArray(), $expect);
+ }
+
+ function test_criteria_parameters_array()
+ {
+ $expect = array("One", "two", 3);
+ $criteria = new TActiveRecordCriteria('sql', $expect);
+ $this->assertEqual($criteria->getParameters()->toArray(), $expect);
+ }
+}
diff --git a/tests/unit/Data/ActiveRecord/DeleteByPkTest.php b/tests/unit/Data/ActiveRecord/DeleteByPkTest.php
new file mode 100644
index 00000000..2f2c09c9
--- /dev/null
+++ b/tests/unit/Data/ActiveRecord/DeleteByPkTest.php
@@ -0,0 +1,33 @@
+<?php
+
+Prado::using('System.Data.ActiveRecord.TActiveRecord');
+require_once(dirname(__FILE__).'/records/DepartmentRecord.php');
+require_once(dirname(__FILE__).'/records/DepSections.php');
+
+/**
+ * @package System.Data.ActiveRecord
+ */
+class DeleteByPkTest extends PHPUnit_Framework_TestCase
+{
+ function setup()
+ {
+ $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test');
+ TActiveRecordManager::getInstance()->setDbConnection($conn);
+ }
+
+ function test_delete_by_pks()
+ {
+ $finder = DepartmentRecord::finder();
+ $this->assertEqual($finder->deleteByPk(100),0);
+ $this->assertEqual($finder->deleteByPk(100, 101),0);
+ $this->assertEqual($finder->deleteByPk(array(100, 101)),0);
+ }
+
+ function test_delete_by_composite_pks()
+ {
+ $finder = DepSections::finder();
+ $this->assertEqual($finder->deleteByPk(array(100,101)),0);
+ $this->assertEqual($finder->deleteByPk(array(100, 101), array(102, 103)),0);
+ $this->assertEqual($finder->deleteByPk(array(array(100, 101), array(102, 103))),0);
+ }
+} \ No newline at end of file
diff --git a/tests/unit/Data/ActiveRecord/FindByPksTest.php b/tests/unit/Data/ActiveRecord/FindByPksTest.php
new file mode 100644
index 00000000..8235352c
--- /dev/null
+++ b/tests/unit/Data/ActiveRecord/FindByPksTest.php
@@ -0,0 +1,65 @@
+<?php
+Prado::using('System.Data.ActiveRecord.TActiveRecord');
+require_once(dirname(__FILE__).'/records/DepartmentRecord.php');
+require_once(dirname(__FILE__).'/records/DepSections.php');
+
+/**
+ * @package System.Data.ActiveRecord
+ */
+class FindByPksTest extends PHPUnit_Framework_TestCase
+{
+ function setup()
+ {
+ $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test');
+ TActiveRecordManager::getInstance()->setDbConnection($conn);
+ }
+
+ function test_find_by_1pk()
+ {
+ $dep = DepartmentRecord::finder()->findByPk(1);
+ $this->assertNotNull($dep);
+ $this->assertEqual($dep->department_id, 1);
+ }
+
+ function test_find_by_1pk_array()
+ {
+ $dep = DepartmentRecord::finder()->findByPk(array(1));
+ $this->assertNotNull($dep);
+ $this->assertEqual($dep->department_id, 1);
+ }
+
+ function test_find_by_pks()
+ {
+ $deps = DepartmentRecord::finder()->findAllByPks(1,2,4);
+ $this->assertEqual(count($deps), 3);
+
+ $this->assertEqual($deps[0]->department_id, 1);
+ $this->assertEqual($deps[1]->department_id, 2);
+ $this->assertEqual($deps[2]->department_id, 4);
+ }
+
+ function test_find_by_pks_with_invalid()
+ {
+ $deps = DepartmentRecord::finder()->findAllByPks(4,2,14);
+ $this->assertEqual(count($deps), 2);
+
+ $this->assertEqual($deps[0]->department_id, 2);
+ $this->assertEqual($deps[1]->department_id, 4);
+ }
+
+ function test_find_by_composite_pks()
+ {
+ $ds = DepSections::finder()->findAllByPks(array(1,1), array(2,5));
+ $this->assertEqual(count($ds), 2);
+
+ $this->assertIsDepSection($ds[0], 1, 1);
+ $this->assertIsDepSection($ds[1], 2, 5);
+ }
+
+ function assertIsDepSection($dep, $dep_id, $sec_id)
+ {
+ $this->assertTrue($dep instanceof DepSections);
+ $this->assertEqual($dep->department_id, $dep_id);
+ $this->assertEqual($dep->section_id, $sec_id);
+ }
+}
diff --git a/tests/unit/Data/ActiveRecord/FindBySqlTest.php b/tests/unit/Data/ActiveRecord/FindBySqlTest.php
new file mode 100644
index 00000000..98113b06
--- /dev/null
+++ b/tests/unit/Data/ActiveRecord/FindBySqlTest.php
@@ -0,0 +1,47 @@
+<?php
+Prado::using('System.Data.ActiveRecord.TActiveRecord');
+require_once(dirname(__FILE__).'/records/DepartmentRecord.php');
+require_once(dirname(__FILE__).'/records/UserRecord.php');
+
+/**
+ * @package System.Data.ActiveRecord
+ */
+class UserRecord2 extends UserRecord
+{
+ public $another_value;
+}
+
+class SqlTest extends TActiveRecord
+{
+ public $category;
+ public $item;
+
+ const TABLE='items';
+}
+
+class FindBySqlTest extends PHPUnit_Framework_TestCase
+{
+ function setup()
+ {
+ $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test');
+ TActiveRecordManager::getInstance()->setDbConnection($conn);
+ }
+
+ function test_find_by_sql()
+ {
+ $deps = DepartmentRecord::finder()->findBySql('SELECT * FROM departments');
+ $this->assertTrue(count($deps) > 0);
+ }
+
+ function test_find_by_sql_arb()
+ {
+ $sql = 'SELECT c.name as category, i.name as item
+ FROM items i, categories c
+ WHERE i.category_id = c.category_id LIMIT 2';
+ $items = TActiveRecord::finder('SqlTest')->findBySql($sql);
+
+ $sql = "SELECT users.*, 'hello' as another_value FROM users LIMIT 2";
+ $users = TActiveRecord::finder('UserRecord2')->findBySql($sql);
+ var_dump($users);
+ }
+}
diff --git a/tests/unit/Data/ActiveRecord/ForeignKeyTest.php b/tests/unit/Data/ActiveRecord/ForeignKeyTest.php
new file mode 100644
index 00000000..99c8b527
--- /dev/null
+++ b/tests/unit/Data/ActiveRecord/ForeignKeyTest.php
@@ -0,0 +1,176 @@
+<?php
+
+Prado::using('System.Data.ActiveRecord.TActiveRecord');
+require_once(dirname(__FILE__).'/records/ItemRecord.php');
+
+/**
+ * @package System.Data.ActiveRecord
+ */
+abstract class SqliteRecord extends TActiveRecord
+{
+ protected static $conn;
+
+ public function getDbConnection()
+ {
+ if(self::$conn===null)
+ self::$conn = new TDbConnection('sqlite:'.dirname(__FILE__).'/fk_tests.db');
+ return self::$conn;
+ }
+}
+
+class Album extends SqliteRecord
+{
+ public $title;
+
+ public $Tracks = array();
+ public $Artists = array();
+
+ public $cover;
+
+ public static $RELATIONS = array(
+ 'Tracks' => array(self::HAS_MANY, 'Track'),
+ 'Artists' => array(self::MANY_TO_MANY, 'Artist', 'album_artists'),
+ 'cover' => array(self::HAS_ONE, 'Cover')
+ );
+
+ public static function finder($class=__CLASS__)
+ {
+ return parent::finder($class);
+ }
+}
+
+class Artist extends SqliteRecord
+{
+ public $name;
+
+ public $Albums = array();
+
+ public static $RELATIONS=array
+ (
+ 'Albums' => array(self::MANY_TO_MANY, 'Album', 'album_artists')
+ );
+
+ public static function finder($class=__CLASS__)
+ {
+ return parent::finder($class);
+ }
+}
+
+class Track extends SqliteRecord
+{
+ public $id;
+ public $song_name;
+ public $album_id; //FK -> Album.id
+
+ public $Album;
+
+ public static $RELATIONS = array(
+ 'Album' => array(self::BELONGS_TO, 'Album'),
+ );
+
+ public static function finder($class=__CLASS__)
+ {
+ return parent::finder($class);
+ }
+}
+
+class Cover extends SqliteRecord
+{
+ public $album;
+ public $content;
+}
+
+class ForeignKeyTest extends PHPUnit_Framework_TestCase
+{
+ function test_has_many()
+ {
+ $albums = Album::finder()->withTracks()->findAll();
+ $this->assertEqual(count($albums), 2);
+
+ $this->assertEqual($albums[0]->title, 'Album 1');
+ $this->assertEqual($albums[1]->title, 'Album 2');
+
+ $this->assertEqual(count($albums[0]->Artists), 0);
+ $this->assertEqual(count($albums[1]->Artists), 0);
+
+ $this->assertEqual(count($albums[0]->Tracks), 3);
+ $this->assertEqual(count($albums[1]->Tracks), 2);
+
+ $this->assertEqual($albums[0]->Tracks[0]->song_name, 'Track 1');
+ $this->assertEqual($albums[0]->Tracks[1]->song_name, 'Song 2');
+ $this->assertEqual($albums[0]->Tracks[2]->song_name, 'Song 3');
+
+ $this->assertEqual($albums[1]->Tracks[0]->song_name, 'Track A');
+ $this->assertEqual($albums[1]->Tracks[1]->song_name, 'Track B');
+ }
+
+ function test_has_one()
+ {
+ $albums = Album::finder()->with_cover()->findAll();
+ $this->assertEqual(count($albums), 2);
+
+ $this->assertEqual($albums[0]->title, 'Album 1');
+ $this->assertEqual($albums[1]->title, 'Album 2');
+
+ $this->assertEqual($albums[0]->cover->content, 'lalala');
+ $this->assertEqual($albums[1]->cover->content, 'conver content');
+
+ $this->assertEqual(count($albums[0]->Artists), 0);
+ $this->assertEqual(count($albums[1]->Artists), 0);
+
+ $this->assertEqual(count($albums[0]->Tracks), 0);
+ $this->assertEqual(count($albums[1]->Tracks), 0);
+ }
+
+ function test_belongs_to()
+ {
+ $track = Track::finder()->withAlbum()->find('id = ?', 1);
+
+ $this->assertEqual($track->id, "1");
+ $this->assertEqual($track->song_name, "Track 1");
+ $this->assertEqual($track->Album->title, "Album 1");
+ }
+
+ function test_has_many_associate()
+ {
+ $album = Album::finder()->withArtists()->find('title = ?', 'Album 2');
+ $this->assertEqual($album->title, 'Album 2');
+ $this->assertEqual(count($album->Artists), 3);
+
+ $this->assertEqual($album->Artists[0]->name, 'Dan');
+ $this->assertEqual($album->Artists[1]->name, 'Karl');
+ $this->assertEqual($album->Artists[2]->name, 'Tom');
+ }
+
+ function test_multiple_fk()
+ {
+ $album = Album::finder()->withArtists()->withTracks()->with_cover()->find('title = ?', 'Album 1');
+
+ $this->assertEqual($album->title, 'Album 1');
+ $this->assertEqual(count($album->Artists), 2);
+
+ $this->assertEqual($album->Artists[0]->name, 'Dan');
+ $this->assertEqual($album->Artists[1]->name, 'Jenny');
+
+ $this->assertEqual($album->Tracks[0]->song_name, 'Track 1');
+ $this->assertEqual($album->Tracks[1]->song_name, 'Song 2');
+ $this->assertEqual($album->Tracks[2]->song_name, 'Song 3');
+
+ $this->assertEqual($album->cover->content, 'lalala');
+ }
+
+ function test_self_reference_fk()
+ {
+ $item = ItemRecord::finder()->withRelated_Items()->findByPk(1);
+ $this->assertNotNull($item);
+ $this->assertEqual($item->name, "Professional Work Attire");
+
+ $this->assertEqual(count($item->related_items),2);
+ $this->assertEqual($item->related_items[0]->name, "Nametags");
+ $this->assertEqual($item->related_items[0]->item_id, 2);
+
+ $this->assertEqual($item->related_items[1]->name, "Grooming and Hygiene");
+ $this->assertEqual($item->related_items[1]->item_id, 3);
+ }
+
+}
diff --git a/tests/unit/Data/ActiveRecord/ForeignObjectUpdateTest.php b/tests/unit/Data/ActiveRecord/ForeignObjectUpdateTest.php
new file mode 100644
index 00000000..8b9d0673
--- /dev/null
+++ b/tests/unit/Data/ActiveRecord/ForeignObjectUpdateTest.php
@@ -0,0 +1,243 @@
+<?php
+Prado::using('System.Data.ActiveRecord.TActiveRecord');
+
+/**
+ * @package System.Data.ActiveRecord
+ */
+class BaseFkRecord extends TActiveRecord
+{
+ public function getDbConnection()
+ {
+ static $conn;
+ if($conn===null)
+ {
+ $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test');
+ //$this->OnExecuteCommand[] = array($this,'logger');
+ }
+ return $conn;
+ }
+
+ function logger($sender,$param)
+ {
+ }
+}
+
+class TeamRecord extends BaseFkRecord
+{
+ const TABLE='teams';
+ public $name;
+ public $location;
+
+ public $players=array();
+
+ //define the $player member having has many relationship with PlayerRecord
+ public static $RELATIONS=array
+ (
+ 'players' => array(self::HAS_MANY, 'PlayerRecord'),
+ );
+
+ public static function finder($className=__CLASS__)
+ {
+ return parent::finder($className);
+ }
+}
+
+class PlayerRecord extends BaseFkRecord
+{
+ const TABLE='players';
+ public $player_id;
+ public $age;
+ public $team_name;
+
+ public $team;
+ private $_skills;
+ public $profile;
+
+ public static $RELATIONS=array
+ (
+ 'skills' => array(self::MANY_TO_MANY, 'SkillRecord', 'player_skills'),
+ 'team' => array(self::BELONGS_TO, 'TeamRecord'),
+ 'profile' => array(self::HAS_ONE, 'ProfileRecord'),
+ );
+
+ public static function finder($className=__CLASS__)
+ {
+ return parent::finder($className);
+ }
+
+ public function getSkills()
+ {
+ if($this->_skills===null && $this->player_id !==null)
+ {
+ //lazy load the skill records
+ $this->setSkills($this->withSkills()->findByPk($this->player_id)->skills);
+ }
+ else if($this->_skills===null)
+ {
+ //create new TList;
+ $this->setSkills(new TList());
+ }
+ return $this->_skills;
+ }
+
+ public function setSkills($value)
+ {
+ $this->_skills = $value instanceof TList ? $value : new TList($value);
+ }
+}
+
+class ProfileRecord extends BaseFkRecord
+{
+ const TABLE='profiles';
+ public $fk_player_id;
+ public $salary;
+
+ public $player;
+
+ public static $RELATIONS=array
+ (
+ 'player' => array(self::BELONGS_TO, 'PlayerRecord'),
+ );
+
+ public static function finder($className=__CLASS__)
+ {
+ return parent::finder($className);
+ }
+}
+
+class SkillRecord extends BaseFkRecord
+{
+ const TABLE='skills';
+ public $skill_id;
+ public $name;
+
+ public $players=array();
+
+ public static $RELATIONS=array
+ (
+ 'players' => array(self::MANY_TO_MANY, 'PlayerRecord', 'player_skills'),
+ );
+
+ public static function finder($className=__CLASS__)
+ {
+ return parent::finder($className);
+ }
+
+
+}
+
+class ForeignObjectUpdateTest extends PHPUnit_Framework_TestCase
+{
+ function test_add_has_one()
+ {
+ ProfileRecord::finder()->deleteByPk(3);
+
+ $player = PlayerRecord::finder()->findByPk(3);
+ $player->profile = new ProfileRecord(array('salary'=>50000));
+ $player->save();
+
+ //test insert
+ $player2 = PlayerRecord::finder()->withProfile()->findByPk(3);
+ $this->assertEqual($player2->profile->salary,50000);
+
+ $player2->profile->salary = 45000;
+ $player2->save();
+ $this->assertEqual($player2->profile->salary,45000);
+
+ //test update
+ $player3 = PlayerRecord::finder()->withProfile()->findByPk(3);
+ $this->assertEqual($player3->profile->salary,45000);
+ }
+
+ function test_add_many()
+ {
+ PlayerRecord::finder()->deleteAll("player_id > ?", 3);
+
+ $team = TeamRecord::finder()->findByPk('Team b');
+ $team->players[] = new PlayerRecord(array('age'=>20));
+ $team->players[] = new PlayerRecord(array('age'=>25));
+ $team->save();
+
+ //test insert
+ $team1 = TeamRecord::finder()->withPlayers()->findByPk('Team b');
+ $this->assertEqual(count($team1->players),3);
+ $this->assertEqual($team1->players[0]->age, 18);
+ $this->assertEqual($team1->players[1]->age, 20);
+ $this->assertEqual($team1->players[2]->age, 25);
+
+ //test update
+ $team1->players[1]->age = 55;
+ $team1->save();
+
+ $this->assertEqual($team1->players[0]->age, 18);
+ $this->assertEqual($team1->players[1]->age, 55);
+ $this->assertEqual($team1->players[2]->age, 25);
+
+ $criteria = new TActiveRecordCriteria();
+ $criteria->OrdersBy['age'] = 'desc';
+ $team2 = TeamRecord::finder()->withPlayers($criteria)->findByPk('Team b');
+ $this->assertEqual(count($team2->players),3);
+ //ordered by age
+ $this->assertEqual($team2->players[0]->age, 55);
+ $this->assertEqual($team2->players[1]->age, 25);
+ $this->assertEqual($team2->players[2]->age, 18);
+ }
+
+ function test_add_belongs_to()
+ {
+ TeamRecord::finder()->deleteByPk('Team c');
+ PlayerRecord::finder()->deleteAll("player_id > ?", 3);
+
+ $player = new PlayerRecord(array('age'=>27));
+ $player->team = new TeamRecord(array('name'=>'Team c', 'location'=>'Sydney'));
+ $player->save();
+
+ //test insert
+ $player1 = PlayerRecord::finder()->withTeam()->findByAge(27);
+ $this->assertNotNull($player1);
+ $this->assertNotNull($player1->team);
+ $this->assertEqual($player1->team->name, 'Team c');
+ $this->assertEqual($player1->team->location, 'Sydney');
+ }
+
+ function test_add_many_via_association()
+ {
+ PlayerRecord::finder()->deleteAll("player_id > ?", 3);
+ SkillRecord::finder()->deleteAll("skill_id > ?", 3);
+
+ $player = new PlayerRecord(array('age'=>37));
+ $player->skills[] = new SkillRecord(array('name'=>'Bash'));
+ $player->skills[] = new SkillRecord(array('name'=>'Jump'));
+ $player->save();
+
+ //test insert
+ $player2 = PlayerRecord::finder()->withSkills()->findByAge(37);
+ $this->assertNotNull($player2);
+ $this->assertEqual(count($player2->skills), 2);
+ $this->assertEqual($player2->skills[0]->name, 'Bash');
+ $this->assertEqual($player2->skills[1]->name, 'Jump');
+
+ //test update
+ $player2->skills[1]->name = "Skip";
+ $player2->skills[] = new SkillRecord(array('name'=>'Push'));
+ $player2->save();
+
+ $criteria = new TActiveRecordCriteria();
+ $criteria->OrdersBy['name'] = 'asc';
+ $player3 = PlayerRecord::finder()->withSkills($criteria)->findByAge(37);
+ $this->assertNotNull($player3);
+ $this->assertEqual(count($player3->skills), 3);
+ $this->assertEqual($player3->skills[0]->name, 'Bash');
+ $this->assertEqual($player3->skills[1]->name, 'Push');
+ $this->assertEqual($player3->skills[2]->name, 'Skip');
+
+ //test lazy load
+ $player4 = PlayerRecord::finder()->findByAge(37);
+ $this->assertEqual(count($player4->skills), 3);
+
+ $this->assertEqual($player4->skills[0]->name, 'Bash');
+ $this->assertEqual($player4->skills[1]->name, 'Skip');
+ $this->assertEqual($player4->skills[2]->name, 'Push');
+ }
+//*/
+}
diff --git a/tests/unit/Data/ActiveRecord/MultipleForeignKeyTest.php b/tests/unit/Data/ActiveRecord/MultipleForeignKeyTest.php
new file mode 100644
index 00000000..d8c54b03
--- /dev/null
+++ b/tests/unit/Data/ActiveRecord/MultipleForeignKeyTest.php
@@ -0,0 +1,193 @@
+<?php
+
+Prado::using('System.Data.ActiveRecord.TActiveRecord');
+
+/**
+ * @package System.Data.ActiveRecord
+ */
+abstract class MultipleFKSqliteRecord extends TActiveRecord
+{
+ protected static $conn;
+
+ public function getDbConnection()
+ {
+ if(self::$conn===null)
+ self::$conn = new TDbConnection('sqlite:'.dirname(__FILE__).'/test1.sqlite');
+ return self::$conn;
+ }
+}
+
+/**
+ *
+CREATE TABLE table1 (
+id integer PRIMARY KEY AUTOINCREMENT,
+field1 varchar,
+fk1 integer CONSTRAINT fk_id1 REFERENCES table2(id) ON DELETE CASCADE,
+fk2 integer CONSTRAINT fk_id2 REFERENCES table2(id) ON DELETE CASCADE,
+fk3 integer CONSTRAINT fk_id3 REFERENCES table2(id) ON DELETE CASCADE)
+ */
+class Table1 extends MultipleFKSqliteRecord
+{
+ public $id;
+ public $field1;
+ public $fk1;
+ public $fk2;
+ public $fk3;
+
+ public $object1;
+ //public $object2; //commented out for testing __get/__set
+ public $object3;
+
+ public static $RELATIONS = array
+ (
+ 'object1' => array(self::BELONGS_TO, 'Table2', 'fk1'),
+ 'object2' => array(self::BELONGS_TO, 'Table2', 'fk2'),
+ 'object3' => array(self::BELONGS_TO, 'Table2', 'fk3'),
+ );
+
+ public static function finder($class=__CLASS__)
+ {
+ return parent::finder($class);
+ }
+}
+
+/**
+ * CREATE TABLE table2 (id integer PRIMARY KEY AUTOINCREMENT,field1 varchar)
+ */
+class Table2 extends MultipleFKSqliteRecord
+{
+ public $id;
+ public $field1;
+
+ private $_state1;
+ //public $state2; //commented out for testing __get/__set
+ public $state3;
+
+ public static $RELATIONS = array
+ (
+ 'state1' => array(self::HAS_MANY, 'Table1', 'fk1'),
+ 'state2' => array(self::HAS_MANY, 'Table1', 'fk2'),
+ 'state3' => array(self::HAS_ONE, 'Table1', 'fk3'),
+ );
+
+ public function setState1($obj)
+ {
+ $this->_state1 = $obj;
+ }
+
+ public function getState1()
+ {
+ if(is_null($this->_state1))
+ $this->fetchResultsFor('state1');
+ return $this->_state1;
+ }
+
+ public static function finder($class=__CLASS__)
+ {
+ return parent::finder($class);
+ }
+}
+
+
+class CategoryX extends MultipleFKSqliteRecord
+{
+ public $cat_id;
+ public $category_name;
+ public $parent_cat;
+
+ public $parent_category;
+ public $child_categories=array();
+
+ public static $RELATIONS=array
+ (
+ 'parent_category' => array(self::BELONGS_TO, 'CategoryX'),
+ 'child_categories' => array(self::HAS_MANY, 'CategoryX'),
+ );
+
+ public static function finder($class=__CLASS__)
+ {
+ return parent::finder($class);
+ }
+}
+
+class MultipleForeignKeyTest extends PHPUnit_Framework_TestCase
+{
+ function testBelongsTo()
+ {
+ $obj = Table1::finder()->withObject1()->findAll();
+ $this->assertEqual(count($obj), 3);
+ $this->assertEqual($obj[0]->id, '1');
+ $this->assertEqual($obj[1]->id, '2');
+ $this->assertEqual($obj[2]->id, '3');
+
+ $this->assertEqual($obj[0]->object1->id, '1');
+ $this->assertEqual($obj[1]->object1->id, '2');
+ $this->assertEqual($obj[2]->object1->id, '2');
+ }
+
+ function testHasMany()
+ {
+ $obj = Table2::finder()->withState1()->findAll();
+ $this->assertEqual(count($obj), 5);
+
+ $this->assertEqual(count($obj[0]->state1), 1);
+ $this->assertEqual($obj[0]->state1[0]->id, '1');
+
+ $this->assertEqual(count($obj[1]->state1), 2);
+ $this->assertEqual($obj[1]->state1[0]->id, '2');
+ $this->assertEqual($obj[1]->state1[1]->id, '3');
+
+ $this->assertEqual(count($obj[2]->state1), 0);
+ $this->assertEqual($obj[2]->id, '3');
+
+ $this->assertEqual(count($obj[3]->state1), 0);
+ $this->assertEqual($obj[3]->id, '4');
+ }
+
+ function testHasOne()
+ {
+ $obj = Table2::finder()->withState3('id = 3')->findAll();
+
+ $this->assertEqual(count($obj), 5);
+
+ $this->assertEqual($obj[0]->id, '1');
+ $this->assertNull($obj[0]->state3);
+
+ $this->assertEqual($obj[1]->id, '2');
+ $this->assertNull($obj[1]->state3);
+
+ $this->assertEqual($obj[2]->id, '3');
+ $this->assertNotNull($obj[2]->state3);
+ $this->assertEqual($obj[2]->state3->id, '3');
+
+ $this->assertEqual($obj[3]->id, '4');
+ $this->assertNull($obj[3]->state3);
+ }
+
+ function testParentChild()
+ {
+ $obj = CategoryX::finder()->withChild_Categories()->withParent_Category()->findByPk(2);
+
+ $this->assertEqual($obj->cat_id, '2');
+ $this->assertEqual(count($obj->child_categories), 2);
+ $this->assertNotNull($obj->parent_category);
+
+ $this->assertEqual($obj->child_categories[0]->cat_id, 3);
+ $this->assertEqual($obj->child_categories[1]->cat_id, 4);
+
+ $this->assertEqual($obj->parent_category->cat_id, 1);
+ }
+
+ function testLazyLoadingGetterSetter_hasMany()
+ {
+ $arr = Table2::finder()->findByPk(2);
+
+ $this->assertNotNull($arr->state2); //lazy load
+ $this->assertEqual(count($arr->state2), 1);
+ $this->assertEqual($arr->state2[0]->id, "1");
+ $this->assertNotNull($arr->state2[0]->object2);
+ $this->assertEqual($arr->state2[0]->object2->id, "2");
+
+ $this->assertNotIdentical($arr, $arr->state2[0]->object2);
+ }
+}
diff --git a/tests/unit/Data/ActiveRecord/RecordEventTest.php b/tests/unit/Data/ActiveRecord/RecordEventTest.php
new file mode 100644
index 00000000..0114e0a4
--- /dev/null
+++ b/tests/unit/Data/ActiveRecord/RecordEventTest.php
@@ -0,0 +1,38 @@
+<?php
+Prado::using('System.Data.ActiveRecord.TActiveRecord');
+require_once(dirname(__FILE__).'/records/UserRecord.php');
+
+/**
+ * @package System.Data.ActiveRecord
+ */
+class RecordEventTest extends PHPUnit_Framework_TestCase
+{
+ function setup()
+ {
+ $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test');
+ TActiveRecordManager::getInstance()->setDbConnection($conn);
+ }
+
+ function testFindByPk()
+ {
+ $user1 = UserRecord::finder()->findByPk('admin');
+ $this->assertNotNull($user1);
+ }
+
+ function test_same_data_returns_same_object()
+ {
+ $criteria = new TActiveRecordCriteria('username = ?', 'admin');
+ $finder = new UserRecord();
+ $finder->OnCreateCommand[] = array($this, 'logger');
+ $finder->OnExecuteCommand[] = array($this, 'logger');
+ $user1 = $finder->find($criteria);
+ //var_dump($user1);
+
+ //var_dump(UserRecord::finder()->find($criteria));
+ }
+
+ function logger($sender, $param)
+ {
+ //var_dump($param);
+ }
+}
diff --git a/tests/unit/Data/ActiveRecord/SqliteTest.php b/tests/unit/Data/ActiveRecord/SqliteTest.php
new file mode 100644
index 00000000..c7f8f515
--- /dev/null
+++ b/tests/unit/Data/ActiveRecord/SqliteTest.php
@@ -0,0 +1,22 @@
+<?php
+Prado::using('System.Data.ActiveRecord.TActiveRecord');
+require_once(dirname(__FILE__).'/records/SqliteUsers.php');
+
+/**
+ * @package System.Data.ActiveRecord
+ */
+class SqliteTest extends PHPUnit_Framework_TestCase
+{
+ function setup()
+ {
+ $conn = new TDbConnection('sqlite2:'.dirname(__FILE__).'/ar_test.db');
+ TActiveRecordManager::getInstance()->setDbConnection($conn);
+ }
+
+ function test_finder()
+ {
+ $finder = SqliteUsers::finder();
+ $user = $finder->findByPk('test');
+ $this->assertNotNull($user);
+ }
+}
diff --git a/tests/unit/Data/ActiveRecord/UserRecordTest.php b/tests/unit/Data/ActiveRecord/UserRecordTest.php
new file mode 100644
index 00000000..c582e95b
--- /dev/null
+++ b/tests/unit/Data/ActiveRecord/UserRecordTest.php
@@ -0,0 +1,67 @@
+<?php
+Prado::using('System.Data.ActiveRecord.TActiveRecord');
+require_once(dirname(__FILE__).'/records/UserRecord.php');
+
+/**
+ * @package System.Data.ActiveRecord
+ */
+class UserRecordTest extends PHPUnit_Framework_TestCase
+{
+ function setup()
+ {
+ $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test');
+ TActiveRecordManager::getInstance()->setDbConnection($conn);
+ }
+
+ function testFindByPk()
+ {
+ $user1 = UserRecord::finder()->findByPk('admin');
+ $this->assertNotNull($user1);
+ }
+
+ function test_same_data_returns_different_instance()
+ {
+ $user1 = UserRecord::finder()->findByPk('admin');
+ $this->assertNotNull($user1);
+
+ $user2 = UserRecord::finder()->findByPk('admin');
+ $this->assertFalse($user1===$user2);
+ }
+
+ function testFindByPk_returns_null()
+ {
+ $user = UserRecord::finder()->findByPk('me');
+ $this->assertNull($user);
+ }
+
+ function test_Create_new_user_returns_true()
+ {
+ $user = new UserRecord;
+ $user->username = 'hello';
+ $user->password = md5('asd');
+ $user->email = 'asdasd';
+ $user->first_name = 'wei';
+ $user->last_name = 'zhuo';
+
+ $this->assertTrue($user->save());
+
+ $user->password = md5('more');
+
+ $this->assertTrue($user->save());
+
+ $check = UserRecord::finder()->findByPk('hello');
+
+ $this->assertSameUser($user, $check);
+
+ $this->assertTrue($user->delete());
+ }
+
+ function assertSameUser($user,$check)
+ {
+ $props = array('username', 'password', 'email', 'first_name', 'last_name', 'job_title',
+ 'work_phone', 'work_fax', 'active', 'department_id', 'salutation',
+ 'hint_question', 'hint_answer');
+ foreach($props as $prop)
+ $this->assertEqual($user->$prop,$check->$prop);
+ }
+}
diff --git a/tests/unit/Data/ActiveRecord/ViewRecordTest.php b/tests/unit/Data/ActiveRecord/ViewRecordTest.php
new file mode 100644
index 00000000..f319e45f
--- /dev/null
+++ b/tests/unit/Data/ActiveRecord/ViewRecordTest.php
@@ -0,0 +1,78 @@
+<?php
+
+
+Prado::using('System.Data.ActiveRecord.TActiveRecord');
+require_once(dirname(__FILE__).'/records/SimpleUser.php');
+
+/**
+ * @package System.Data.ActiveRecord
+ */
+class ViewRecordTest extends PHPUnit_Framework_TestCase
+{
+ function setup()
+ {
+ $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test');
+ TActiveRecordManager::getInstance()->setDbConnection($conn);
+ }
+
+ function test_view_record()
+ {
+ $users = SimpleUser::finder()->findAll();
+ $this->assertTrue(count($users) > 0);
+ }
+
+ function test_save_view_record_throws_exception()
+ {
+ $user = new SimpleUser();
+ try
+ {
+ $user->save();
+ $this->fail();
+ }
+ catch(TActiveRecordException $e)
+ {
+ $this->pass();
+ }
+ }
+
+ function test_update_view_record_throws_exception()
+ {
+ $user = SimpleUser::finder()->findByUsername('admin');
+ $user->username = 'ads';
+ try
+ {
+ $user->save();
+ $this->fail();
+ }
+ catch(TActiveRecordException $e)
+ {
+ $this->pass();
+ }
+ }
+
+ function test_find_by_pk_throws_exception()
+ {
+ try
+ {
+ $user = SimpleUser::finder()->findByPk('admin');
+ $this->fail();
+ }
+ catch(TDbException $e)
+ {
+ $this->pass();
+ }
+ }
+
+ function test_delete_by_pk_throws_exception()
+ {
+ try
+ {
+ SimpleUser::finder()->deleteByPk('admin');
+ $this->fail();
+ }
+ catch(TDbException $e)
+ {
+ $this->pass();
+ }
+ }
+} \ No newline at end of file
diff --git a/tests/unit/Data/ActiveRecord/ar_test.db b/tests/unit/Data/ActiveRecord/ar_test.db
new file mode 100644
index 00000000..7549bb66
--- /dev/null
+++ b/tests/unit/Data/ActiveRecord/ar_test.db
Binary files differ
diff --git a/tests/unit/Data/ActiveRecord/blog.db b/tests/unit/Data/ActiveRecord/blog.db
new file mode 100644
index 00000000..30a9cb7a
--- /dev/null
+++ b/tests/unit/Data/ActiveRecord/blog.db
Binary files differ
diff --git a/tests/unit/Data/ActiveRecord/fk_tests.db b/tests/unit/Data/ActiveRecord/fk_tests.db
new file mode 100644
index 00000000..87835c84
--- /dev/null
+++ b/tests/unit/Data/ActiveRecord/fk_tests.db
Binary files differ
diff --git a/tests/unit/Data/ActiveRecord/mysql4text.sql b/tests/unit/Data/ActiveRecord/mysql4text.sql
new file mode 100644
index 00000000..03d2c010
--- /dev/null
+++ b/tests/unit/Data/ActiveRecord/mysql4text.sql
@@ -0,0 +1,52 @@
+CREATE TABLE album (
+ title varchar(100) NOT NULL default '',
+ PRIMARY KEY (title)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE artist (
+ name varchar(25) NOT NULL default '',
+ PRIMARY KEY (name)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE album_artists (
+ album_title varchar(100) NOT NULL default '',
+ artist_name varchar(25) NOT NULL default '',
+ PRIMARY KEY (album_title,artist_name),
+ KEY FK_album_artists_2 (artist_name)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE track (
+ id int(11) NOT NULL auto_increment,
+ song_name varchar(200) NOT NULL default '',
+ album_id varchar(100) NOT NULL default '',
+ PRIMARY KEY (id),
+ KEY album_id (album_id)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+ALTER TABLE album_artists
+ ADD CONSTRAINT FK_album_artists_2 FOREIGN KEY (artist_name) REFERENCES artist (name),
+ ADD CONSTRAINT FK_album_artists_1 FOREIGN KEY (album_title) REFERENCES album (title);
+
+ALTER TABLE track
+ ADD CONSTRAINT track_ibfk_1 FOREIGN KEY (album_id) REFERENCES album (title);
+
+
+INSERT INTO album (title) VALUES ('Album 1');
+INSERT INTO album (title) VALUES ('Album 2');
+
+INSERT INTO artist (name) VALUES ('Dan');
+INSERT INTO artist (name) VALUES ('Jenny');
+INSERT INTO artist (name) VALUES ('Karl');
+INSERT INTO artist (name) VALUES ('Tom');
+
+INSERT INTO album_artists (album_title, artist_name) VALUES ('Album 1', 'Dan');
+INSERT INTO album_artists (album_title, artist_name) VALUES ('Album 2', 'Dan');
+INSERT INTO album_artists (album_title, artist_name) VALUES ('Album 1', 'Jenny');
+INSERT INTO album_artists (album_title, artist_name) VALUES ('Album 2', 'Karl');
+INSERT INTO album_artists (album_title, artist_name) VALUES ('Album 2', 'Tom');
+
+INSERT INTO track (id, song_name, album_id) VALUES (1, 'Track 1', 'Album 1');
+INSERT INTO track (id, song_name, album_id) VALUES (2, 'Song 2', 'Album 1');
+INSERT INTO track (id, song_name, album_id) VALUES (3, 'Track A', 'Album 2');
+INSERT INTO track (id, song_name, album_id) VALUES (4, 'Track B', 'Album 2');
+INSERT INTO track (id, song_name, album_id) VALUES (5, 'Song 3', 'Album 1'); \ No newline at end of file
diff --git a/tests/unit/Data/ActiveRecord/records/Blogs.php b/tests/unit/Data/ActiveRecord/records/Blogs.php
new file mode 100644
index 00000000..6523f029
--- /dev/null
+++ b/tests/unit/Data/ActiveRecord/records/Blogs.php
@@ -0,0 +1,12 @@
+<?php
+class Blogs extends TActiveRecord
+{
+ public $blog_id;
+ public $blog_name;
+ public $blog_author;
+
+ public static function finder($className=__CLASS__)
+ {
+ return parent::finder($className);
+ }
+}
diff --git a/tests/unit/Data/ActiveRecord/records/DepSections.php b/tests/unit/Data/ActiveRecord/records/DepSections.php
new file mode 100644
index 00000000..bf01ed12
--- /dev/null
+++ b/tests/unit/Data/ActiveRecord/records/DepSections.php
@@ -0,0 +1,14 @@
+<?php
+class DepSections extends TActiveRecord
+{
+ public $department_id;
+ public $section_id;
+ public $order;
+
+ const TABLE='department_sections';
+
+ public static function finder($className=__CLASS__)
+ {
+ return parent::finder($className);
+ }
+}
diff --git a/tests/unit/Data/ActiveRecord/records/DepartmentRecord.php b/tests/unit/Data/ActiveRecord/records/DepartmentRecord.php
new file mode 100644
index 00000000..b60c7930
--- /dev/null
+++ b/tests/unit/Data/ActiveRecord/records/DepartmentRecord.php
@@ -0,0 +1,16 @@
+<?php
+class DepartmentRecord extends TActiveRecord
+{
+ public $department_id;
+ public $name;
+ public $description;
+ public $active;
+ public $order;
+
+ const TABLE = 'departments';
+
+ public static function finder($className=__CLASS__)
+ {
+ return parent::finder($className);
+ }
+}
diff --git a/tests/unit/Data/ActiveRecord/records/ItemRecord.php b/tests/unit/Data/ActiveRecord/records/ItemRecord.php
new file mode 100644
index 00000000..e6707cde
--- /dev/null
+++ b/tests/unit/Data/ActiveRecord/records/ItemRecord.php
@@ -0,0 +1,47 @@
+<?php
+
+class ItemRecord extends TActiveRecord
+{
+ const TABLE='items';
+ public $item_id;
+ public $name;
+ public $brand_specific;
+ public $description;
+ public $meta;
+ public $active;
+ public $need_review;
+ public $category_id;
+ public $type_id;
+ public $content;
+ public $standard_id;
+ public $timestamp;
+
+ public $related_items = array();
+ public $related_item_id;
+
+ public static $RELATIONS=array
+ (
+ 'related_items' => array(self::MANY_TO_MANY, 'ItemRecord', 'related_items.related_item_id'),
+ );
+
+ public function getDbConnection()
+ {
+ static $conn;
+ if($conn===null)
+ {
+ $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test');
+ $this->OnExecuteCommand[] = array($this,'logger');
+ }
+ return $conn;
+ }
+
+ public function logger($sender,$param)
+ {
+ //var_dump($param->Command->Text);
+ }
+
+ public static function finder($className=__CLASS__)
+ {
+ return parent::finder($className);
+ }
+}
diff --git a/tests/unit/Data/ActiveRecord/records/SimpleUser.php b/tests/unit/Data/ActiveRecord/records/SimpleUser.php
new file mode 100644
index 00000000..b6748857
--- /dev/null
+++ b/tests/unit/Data/ActiveRecord/records/SimpleUser.php
@@ -0,0 +1,12 @@
+<?php
+class SimpleUser extends TActiveRecord
+{
+ public $username;
+
+ const TABLE='simple_users';
+
+ public static function finder($className=__CLASS__)
+ {
+ return parent::finder($className);
+ }
+}
diff --git a/tests/unit/Data/ActiveRecord/records/SqliteUsers.php b/tests/unit/Data/ActiveRecord/records/SqliteUsers.php
new file mode 100644
index 00000000..f8fa12c5
--- /dev/null
+++ b/tests/unit/Data/ActiveRecord/records/SqliteUsers.php
@@ -0,0 +1,14 @@
+<?php
+class SqliteUsers extends TActiveRecord
+{
+ public $username;
+ public $password;
+ public $email;
+
+ const TABLE='users';
+
+ public static function finder($className=__CLASS__)
+ {
+ return parent::finder($className);
+ }
+}
diff --git a/tests/unit/Data/ActiveRecord/records/UserRecord.php b/tests/unit/Data/ActiveRecord/records/UserRecord.php
new file mode 100644
index 00000000..4ef98baf
--- /dev/null
+++ b/tests/unit/Data/ActiveRecord/records/UserRecord.php
@@ -0,0 +1,36 @@
+<?php
+class UserRecord extends TActiveRecord
+{
+ public $username;
+ public $password;
+ public $email;
+ public $first_name;
+ public $last_name;
+ public $job_title;
+ public $work_phone;
+ public $work_fax;
+ public $active=true;
+ public $department_id;
+ public $salutation;
+ public $hint_question;
+ public $hint_answer;
+
+ private $_level=-1;
+
+ const TABLE='users';
+
+ public function getLevel()
+ {
+ return $this->_level;
+ }
+
+ public function setLevel($level)
+ {
+ $this->_level=TPropertyValue::ensureInteger($level);
+ }
+
+ public static function finder($className=__CLASS__)
+ {
+ return parent::finder($className);
+ }
+}
diff --git a/tests/unit/Data/ActiveRecord/sqlite.sql b/tests/unit/Data/ActiveRecord/sqlite.sql
new file mode 100644
index 00000000..7854fc43
--- /dev/null
+++ b/tests/unit/Data/ActiveRecord/sqlite.sql
@@ -0,0 +1,46 @@
+CREATE TABLE album (
+ title varchar(100) NOT NULL PRIMARY KEY
+);
+
+CREATE TABLE artist (
+ name varchar(25) NOT NULL PRIMARY KEY
+);
+
+CREATE TABLE album_artists (
+ album_title varchar(100) NOT NULL CONSTRAINT fk_album REFERENCES album(title) ON DELETE CASCADE,
+ artist_name varchar(25) NOT NULL CONSTRAINT fk_artist REFERENCES artist(name) ON DELETE CASCADE
+);
+
+CREATE TABLE track (
+ id INTEGER NOT NULL PRIMARY KEY,
+ song_name varchar(200) NOT NULL default '',
+ album_id varchar(100) NOT NULL CONSTRAINT fk_album_1 REFERENCES album(title) ON DELETE CASCADE
+);
+
+CREATE TABLE cover(
+ album varchar(200) NOT NULL CONSTRAINT fk_album_2 REFERENCES album(title) ON DELETE CASCADE,
+ content text
+);
+
+INSERT INTO album (title) VALUES ('Album 1');
+INSERT INTO album (title) VALUES ('Album 2');
+
+INSERT INTO cover(album,content) VALUES ('Album 1', 'lalala');
+INSERT INTO cover(album,content) VALUES ('Album 2', 'conver content');
+
+INSERT INTO artist (name) VALUES ('Dan');
+INSERT INTO artist (name) VALUES ('Jenny');
+INSERT INTO artist (name) VALUES ('Karl');
+INSERT INTO artist (name) VALUES ('Tom');
+
+INSERT INTO album_artists (album_title, artist_name) VALUES ('Album 1', 'Dan');
+INSERT INTO album_artists (album_title, artist_name) VALUES ('Album 2', 'Dan');
+INSERT INTO album_artists (album_title, artist_name) VALUES ('Album 1', 'Jenny');
+INSERT INTO album_artists (album_title, artist_name) VALUES ('Album 2', 'Karl');
+INSERT INTO album_artists (album_title, artist_name) VALUES ('Album 2', 'Tom');
+
+INSERT INTO track (id, song_name, album_id) VALUES (1, 'Track 1', 'Album 1');
+INSERT INTO track (id, song_name, album_id) VALUES (2, 'Song 2', 'Album 1');
+INSERT INTO track (id, song_name, album_id) VALUES (3, 'Track A', 'Album 2');
+INSERT INTO track (id, song_name, album_id) VALUES (4, 'Track B', 'Album 2');
+INSERT INTO track (id, song_name, album_id) VALUES (5, 'Song 3', 'Album 1'); \ No newline at end of file
diff --git a/tests/unit/Data/ActiveRecord/test1.sqlite b/tests/unit/Data/ActiveRecord/test1.sqlite
new file mode 100644
index 00000000..1e056b52
--- /dev/null
+++ b/tests/unit/Data/ActiveRecord/test1.sqlite
Binary files differ
diff --git a/tests/unit/Data/DataGateway/AllTests.php b/tests/unit/Data/DataGateway/AllTests.php
deleted file mode 100644
index 6007ae70..00000000
--- a/tests/unit/Data/DataGateway/AllTests.php
+++ /dev/null
@@ -1,27 +0,0 @@
-<?php
-
-
-if(!defined('PHPUnit_MAIN_METHOD')) {
- define('PHPUnit_MAIN_METHOD', 'Data_DataGateway_AllTests::main');
-}
-
-require_once 'TSqlCriteriaTest.php';
-
-class Data_DataGateway_AllTests {
-
- public static function main() {
- PHPUnit_TextUI_TestRunner::run(self::suite());
- }
-
- public static function suite() {
- $suite = new PHPUnit_Framework_TestSuite('System.Data.DataGateway');
-
- $suite->addTestSuite('TSqlCriteriaTest');
-
- return $suite;
- }
-}
-
-if(PHPUnit_MAIN_METHOD == 'Data_DataGateway_AllTests::main') {
- Data_DataGateway_AllTests::main();
-}
diff --git a/tests/unit/Data/DbCommon/CommandBuilderMssqlTest.php b/tests/unit/Data/DbCommon/CommandBuilderMssqlTest.php
new file mode 100644
index 00000000..893a8ca6
--- /dev/null
+++ b/tests/unit/Data/DbCommon/CommandBuilderMssqlTest.php
@@ -0,0 +1,47 @@
+<?php
+
+Prado::using('System.Data.*');
+Prado::using('System.Data.Common.Mssql.TMssqlCommandBuilder');
+
+/**
+ * @package System.Data.DbCommon
+ */
+class CommandBuilderMssqlTest extends PHPUnit_Framework_TestCase
+{
+ protected static $sql = array(
+ 'simple' => 'SELECT username, age FROM accounts',
+ 'multiple' => 'select a.username, b.name from accounts a, table1 b where a.age = b.id1',
+ 'ordering' => 'select a.username, b.name, a.age from accounts a, table1 b where a.age = b.id1 order by age DESC, name',
+ 'index' => 'select a.username, b.name, a.age from accounts a, table1 b where a.age = b.id1 ORDER BY 1 DESC, 2 ASC',
+ //'compute' => 'SELECT username, age FROM accounts order by age compute avg(age)',
+ );
+
+ function test_limit()
+ {
+ $builder = new TMssqlCommandBuilder();
+
+ $sql = $builder->applyLimitOffset(self::$sql['simple'], 3);
+ $expect = 'SELECT TOP 3 username, age FROM accounts';
+ $this->assertEqual($expect, $sql);
+
+
+ $sql = $builder->applyLimitOffset(self::$sql['simple'], 3, 2);
+ $expect = 'SELECT * FROM (SELECT TOP 3 * FROM (SELECT TOP 5 username, age FROM accounts) as [__inner top table__] ) as [__outer top table__] ';
+ $this->assertEqual($expect, $sql);
+
+ $sql = $builder->applyLimitOffset(self::$sql['multiple'], 3, 2);
+ $expect = 'SELECT * FROM (SELECT TOP 3 * FROM (SELECT TOP 5 a.username, b.name from accounts a, table1 b where a.age = b.id1) as [__inner top table__] ) as [__outer top table__] ';
+ $this->assertEqual($sql, $expect);
+
+ $sql = $builder->applyLimitOffset(self::$sql['ordering'], 3, 2);
+ $expect = 'SELECT * FROM (SELECT TOP 3 * FROM (SELECT TOP 5 a.username, b.name, a.age from accounts a, table1 b where a.age = b.id1 order by age DESC, name) as [__inner top table__] ORDER BY age ASC, name DESC) as [__outer top table__] ORDER BY age DESC, name ASC';
+ $this->assertEqual($sql, $expect);
+
+ $sql = $builder->applyLimitOffset(self::$sql['index'], 3, 2);
+ $expect = 'SELECT * FROM (SELECT TOP 3 * FROM (SELECT TOP 5 a.username, b.name, a.age from accounts a, table1 b where a.age = b.id1 ORDER BY 1 DESC, 2 ASC) as [__inner top table__] ORDER BY 1 ASC, 2 DESC) as [__outer top table__] ORDER BY 1 DESC, 2 ASC';
+ $this->assertEqual($expect, $sql);
+
+ // $sql = $builder->applyLimitOffset(self::$sql['compute'], 3, 2);
+ // var_dump($sql);
+ }
+}
diff --git a/tests/unit/Data/DbCommon/CommandBuilderMysqlTest.php b/tests/unit/Data/DbCommon/CommandBuilderMysqlTest.php
new file mode 100644
index 00000000..77e58019
--- /dev/null
+++ b/tests/unit/Data/DbCommon/CommandBuilderMysqlTest.php
@@ -0,0 +1,20 @@
+<?php
+Prado::using('System.Data.*');
+Prado::using('System.Data.Common.Mysql.TMysqlMetaData');
+
+/**
+ * @package System.Data.DbCommon
+ */
+class CommandBuilderMysqlTest extends PHPUnit_Framework_TestCase
+{
+ function mysql_meta_data()
+ {
+ $conn = new TDbConnection('mysql:host=localhost;dbname=tests;port=3307', 'test5','test5');
+ return new TMysqlMetaData($conn);
+ }
+
+ function test()
+ {
+ $this->mysql_meta_data()->getTableInfo("tests.table1");
+ }
+}
diff --git a/tests/unit/Data/DbCommon/CommandBuilderPgsqlTest.php b/tests/unit/Data/DbCommon/CommandBuilderPgsqlTest.php
new file mode 100644
index 00000000..389ad0e1
--- /dev/null
+++ b/tests/unit/Data/DbCommon/CommandBuilderPgsqlTest.php
@@ -0,0 +1,77 @@
+<?php
+Prado::using('System.Data.*');
+Prado::using('System.Data.Common.Pgsql.TPgsqlMetaData');
+
+/**
+ * @package System.Data.DbCommon
+ */
+class CommandBuilderPgsqlTest extends PHPUnit_Framework_TestCase
+{
+ function pgsql_meta_data()
+ {
+ $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test');
+ return new TPgsqlMetaData($conn);
+ }
+
+ function test_insert_command_using_named_array()
+ {
+ $builder = $this->pgsql_meta_data()->createCommandBuilder('address');
+ $address=array(
+ 'username' => 'Username',
+ 'phone' => 121987,
+ 'field1_boolean' => true,
+ 'field2_date' => '1213',
+ 'field3_double' => 121.1,
+ 'field4_integer' => 345,
+ 'field6_time' => time(),
+ 'field7_timestamp' => time(),
+ 'field8_money' => '121.12',
+ 'field9_numeric' => 984.22,
+ 'int_fk1'=>1,
+ 'int_fk2'=>1,
+ );
+ $insert = $builder->createInsertCommand($address);
+ $sql = 'INSERT INTO public.address("username", "phone", "field1_boolean", "field2_date", "field3_double", "field4_integer", "field6_time", "field7_timestamp", "field8_money", "field9_numeric", "int_fk1", "int_fk2") VALUES (:username, :phone, :field1_boolean, :field2_date, :field3_double, :field4_integer, :field6_time, :field7_timestamp, :field8_money, :field9_numeric, :int_fk1, :int_fk2)';
+ $this->assertEqual($sql, $insert->Text);
+ }
+
+ function test_update_command()
+ {
+ $builder = $this->pgsql_meta_data()->createCommandBuilder('address');
+ $data = array(
+ 'phone' => 9809,
+ 'int_fk1' => 1212,
+ );
+ $update = $builder->createUpdateCommand($data, '1');
+ $sql = 'UPDATE public.address SET "phone" = :phone, "int_fk1" = :int_fk1 WHERE 1';
+ $this->assertEqual($sql, $update->Text);
+ }
+
+ function test_delete_command()
+ {
+ $builder = $this->pgsql_meta_data()->createCommandBuilder('address');
+ $where = 'phone is NULL';
+ $delete = $builder->createDeleteCommand($where);
+ $sql = 'DELETE FROM public.address WHERE phone is NULL';
+ $this->assertEqual($sql, $delete->Text);
+ }
+
+ function test_select_limit()
+ {
+ $meta = $this->pgsql_meta_data();
+ $builder = $meta->createCommandBuilder('address');
+ $query = 'SELECT * FROM '.$meta->getTableInfo('address')->getTableFullName();
+
+ $limit = $builder->applyLimitOffset($query, 1);
+ $expect = $query.' LIMIT 1';
+ $this->assertEqual($expect, $limit);
+
+ $limit = $builder->applyLimitOffset($query, -1, 10);
+ $expect = $query.' OFFSET 10';
+ $this->assertEqual($expect, $limit);
+
+ $limit = $builder->applyLimitOffset($query, 2, 3);
+ $expect = $query.' LIMIT 2 OFFSET 3';
+ $this->assertEqual($expect, $limit);
+ }
+}
diff --git a/tests/unit/Data/DbCommon/MssqlColumnTest.php b/tests/unit/Data/DbCommon/MssqlColumnTest.php
new file mode 100644
index 00000000..e4196fcf
--- /dev/null
+++ b/tests/unit/Data/DbCommon/MssqlColumnTest.php
@@ -0,0 +1,49 @@
+<?php
+
+Prado::using('System.Data.*');
+Prado::using('System.Data.Common.Mssql.TMssqlMetaData');
+Prado::using('System.Data.DataGateway.TTableGateway');
+
+/**
+ * @package System.Data.DbCommon
+ */
+class MssqlColumnTest extends PHPUnit_Framework_TestCase
+{
+ function get_conn()
+ {
+ return new TDbConnection('mssql:host=localhost\\sqlexpress', 'test', 'test01');
+ }
+
+ /**
+ * @return TMssqlMetaData
+ */
+ function meta_data()
+ {
+ return new TMssqlMetaData($this->get_conn());
+ }
+
+ function test_insert()
+ {
+ $table = new TTableGateway('table1', $this->get_conn());
+ $this->assertTrue(is_int($table->insert(array('name'=>'cool'))));
+ }
+
+/* function test_meta()
+ {
+ $result = $this->meta_data()->getTableInfo("bar");
+ var_dump($result);
+ }
+*/
+ /*function test_insert()
+ {
+ $table = new TTableGateway('table1', $this->get_conn());
+ //var_dump($table->insert(array('name'=>'cool')));
+ //var_dump($table->getLastInsertId());
+ $criteria = new TSqlCriteria();
+ $criteria->Limit = 5;
+ $criteria->Offset = 2;
+
+ $result = $table->findAll($criteria)->readAll();
+ var_dump($result);
+ }*/
+}
diff --git a/tests/unit/Data/DbCommon/Mysql4ColumnTest.php b/tests/unit/Data/DbCommon/Mysql4ColumnTest.php
new file mode 100644
index 00000000..74606452
--- /dev/null
+++ b/tests/unit/Data/DbCommon/Mysql4ColumnTest.php
@@ -0,0 +1,255 @@
+<?php
+Prado::using('System.Data.*');
+Prado::using('System.Data.Common.Mysql.TMysqlMetaData');
+
+/**
+ * @package System.Data.DbCommon
+ */
+class Mysql4ColumnTest extends PHPUnit_Framework_TestCase
+{
+ function create_meta_data()
+ {
+ $conn = new TDbConnection('mysql:host=localhost;dbname=tests;port=3306', 'test4','test4');
+ return new TMysqlMetaData($conn);
+ }
+
+ function test_columns()
+ {
+ $table = $this->create_meta_data()->getTableInfo('table1');
+ $this->assertEqual(count($table->getColumns()), 18);
+
+ $columns['id'] = array(
+ 'ColumnName' => '`id`',
+ 'ColumnSize' => 10,
+ 'ColumnIndex' => 0,
+ 'DbType' => 'int unsigned',
+ 'AllowNull' => false,
+ 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => true,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => true,
+ );
+
+ $columns['name'] = array(
+ 'ColumnName' => '`name`',
+ 'ColumnSize' => 45,
+ 'ColumnIndex' => 1,
+ 'DbType' => 'varchar',
+ 'AllowNull' => false,
+ 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => true,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => false,
+ );
+
+ $columns['field1'] = array(
+ 'ColumnName' => '`field1`',
+ 'ColumnSize' => 4,
+ 'ColumnIndex' => 2,
+ 'DbType' => 'tinyint',
+ 'AllowNull' => false,
+ 'DefaultValue' => '0',
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => false,
+ );
+
+ $columns['field2_text'] = array(
+ 'ColumnName' => '`field2_text`',
+ 'ColumnSize' => null,
+ 'ColumnIndex' => 3,
+ 'DbType' => 'text',
+ 'AllowNull' => true,
+ 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => false,
+ );
+
+ $columns['field3_date'] = array(
+ 'ColumnName' => '`field3_date`',
+ 'ColumnSize' => null,
+ 'ColumnIndex' => 4,
+ 'DbType' => 'date',
+ 'AllowNull' => true,
+ 'DefaultValue' => '2007-02-25',
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => false,
+ );
+
+ $columns['field4_float'] = array(
+ 'ColumnName' => '`field4_float`',
+ 'ColumnSize' => null,
+ 'ColumnIndex' => 5,
+ 'DbType' => 'float',
+ 'AllowNull' => false,
+ 'DefaultValue' => 10,
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => false,
+ );
+
+ $columns['field5_float'] = array(
+ 'ColumnName' => '`field5_float`',
+ 'ColumnSize' => null,
+ 'ColumnIndex' => 6,
+ 'DbType' => 'float',
+ 'AllowNull' => false,
+ 'DefaultValue' => '0.0000',
+ 'NumericPrecision' => 5,
+ 'NumericScale' => 4,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => false,
+ );
+
+ $columns['field6_double'] = array(
+ 'ColumnName' => '`field6_double`',
+ 'ColumnSize' => null,
+ 'ColumnIndex' => 7,
+ 'DbType' => 'double',
+ 'AllowNull' => false,
+ 'DefaultValue' => '0',
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => false,
+ );
+
+ $columns['field7_datetime'] = array(
+ 'ColumnName' => '`field7_datetime`',
+ 'ColumnSize' => null,
+ 'ColumnIndex' => 8,
+ 'DbType' => 'datetime',
+ 'AllowNull' => false,
+ 'DefaultValue' => '0000-00-00 00:00:00',
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => false,
+ );
+
+ $columns['field8_timestamp'] = array(
+ 'ColumnName' => '`field8_timestamp`',
+ 'ColumnSize' => null,
+ 'ColumnIndex' => 9,
+ 'DbType' => 'timestamp',
+ 'AllowNull' => true,
+ 'DefaultValue' => 'CURRENT_TIMESTAMP',
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => false,
+ );
+
+ $columns['field9_time'] = array(
+ 'ColumnName' => '`field9_time`',
+ 'ColumnSize' => null,
+ 'ColumnIndex' => 10,
+ 'DbType' => 'time',
+ 'AllowNull' => false,
+ 'DefaultValue' => '00:00:00',
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => false,
+ );
+
+ $columns['field10_year'] = array(
+ 'ColumnName' => '`field10_year`',
+ 'ColumnSize' => 4,
+ 'ColumnIndex' => 11,
+ 'DbType' => 'year',
+ 'AllowNull' => false,
+ 'DefaultValue' => '0000',
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => false,
+ );
+
+ $columns['field11_enum'] = array(
+ 'ColumnName' => '`field11_enum`',
+ 'ColumnSize' => null,
+ 'ColumnIndex' => 12,
+ 'DbType' => 'enum',
+ 'AllowNull' => false,
+ 'DefaultValue' => 'one',
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => false,
+ 'DbTypeValues' => array('one', 'two', 'three'),
+ );
+
+ $columns['field12_SET'] = array(
+ 'ColumnName' => '`field12_SET`',
+ 'ColumnSize' => null,
+ 'ColumnIndex' => 13,
+ 'DbType' => 'set',
+ 'AllowNull' => false,
+ 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => false,
+ 'DbTypeValues' => array('blue', 'red', 'green'),
+ );
+
+ $this->assertColumn($columns, $table);
+
+ $this->assertNull($table->getSchemaName());
+ $this->assertEqual('table1', $table->getTableName());
+ $this->assertEqual(array('id', 'name'), $table->getPrimaryKeys());
+ }
+
+ function assertColumn($columns, $table)
+ {
+ foreach($columns as $id=>$asserts)
+ {
+ $column = $table->Columns[$id];
+ foreach($asserts as $property=>$assert)
+ {
+ $ofAssert= var_export($assert,true);
+ $value = $column->{$property};
+ $ofValue = var_export($value, true);
+ $this->assertEqual($value, $assert,
+ "Column [{$id}] {$property} value {$ofValue} did not match {$ofAssert}");
+ }
+ }
+ }
+}
diff --git a/tests/unit/Data/DbCommon/MysqlColumnTest.php b/tests/unit/Data/DbCommon/MysqlColumnTest.php
new file mode 100644
index 00000000..3bdfe54f
--- /dev/null
+++ b/tests/unit/Data/DbCommon/MysqlColumnTest.php
@@ -0,0 +1,255 @@
+<?php
+Prado::using('System.Data.*');
+Prado::using('System.Data.Common.Mysql.TMysqlMetaData');
+
+/**
+ * @package System.Data.DbCommon
+ */
+class MysqlColumnTest extends PHPUnit_Framework_TestCase
+{
+ function create_meta_data()
+ {
+ $conn = new TDbConnection('mysql:host=localhost;dbname=tests;port=3307', 'test5','test5');
+ return new TMysqlMetaData($conn);
+ }
+
+ function test_columns()
+ {
+ $table = $this->create_meta_data()->getTableInfo('table1');
+ $this->assertEqual(count($table->getColumns()), 18);
+
+ $columns['id'] = array(
+ 'ColumnName' => '`id`',
+ 'ColumnSize' => 10,
+ 'ColumnIndex' => 0,
+ 'DbType' => 'int unsigned',
+ 'AllowNull' => false,
+ 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => true,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => true,
+ );
+
+ $columns['name'] = array(
+ 'ColumnName' => '`name`',
+ 'ColumnSize' => 45,
+ 'ColumnIndex' => 1,
+ 'DbType' => 'varchar',
+ 'AllowNull' => false,
+ 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => true,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => false,
+ );
+
+ $columns['field1'] = array(
+ 'ColumnName' => '`field1`',
+ 'ColumnSize' => 4,
+ 'ColumnIndex' => 2,
+ 'DbType' => 'tinyint',
+ 'AllowNull' => false,
+ 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => false,
+ );
+
+ $columns['field2_text'] = array(
+ 'ColumnName' => '`field2_text`',
+ 'ColumnSize' => null,
+ 'ColumnIndex' => 3,
+ 'DbType' => 'text',
+ 'AllowNull' => true,
+ 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => false,
+ );
+
+ $columns['field3_date'] = array(
+ 'ColumnName' => '`field3_date`',
+ 'ColumnSize' => null,
+ 'ColumnIndex' => 4,
+ 'DbType' => 'date',
+ 'AllowNull' => true,
+ 'DefaultValue' => '2007-02-25',
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => false,
+ );
+
+ $columns['field4_float'] = array(
+ 'ColumnName' => '`field4_float`',
+ 'ColumnSize' => null,
+ 'ColumnIndex' => 5,
+ 'DbType' => 'float',
+ 'AllowNull' => false,
+ 'DefaultValue' => 10,
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => false,
+ );
+
+ $columns['field5_float'] = array(
+ 'ColumnName' => '`field5_float`',
+ 'ColumnSize' => null,
+ 'ColumnIndex' => 6,
+ 'DbType' => 'float',
+ 'AllowNull' => false,
+ 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
+ 'NumericPrecision' => 5,
+ 'NumericScale' => 4,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => false,
+ );
+
+ $columns['field6_double'] = array(
+ 'ColumnName' => '`field6_double`',
+ 'ColumnSize' => null,
+ 'ColumnIndex' => 7,
+ 'DbType' => 'double',
+ 'AllowNull' => false,
+ 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => false,
+ );
+
+ $columns['field7_datetime'] = array(
+ 'ColumnName' => '`field7_datetime`',
+ 'ColumnSize' => null,
+ 'ColumnIndex' => 8,
+ 'DbType' => 'datetime',
+ 'AllowNull' => false,
+ 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => false,
+ );
+
+ $columns['field8_timestamp'] = array(
+ 'ColumnName' => '`field8_timestamp`',
+ 'ColumnSize' => null,
+ 'ColumnIndex' => 9,
+ 'DbType' => 'timestamp',
+ 'AllowNull' => true,
+ 'DefaultValue' => 'CURRENT_TIMESTAMP',
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => false,
+ );
+
+ $columns['field9_time'] = array(
+ 'ColumnName' => '`field9_time`',
+ 'ColumnSize' => null,
+ 'ColumnIndex' => 10,
+ 'DbType' => 'time',
+ 'AllowNull' => false,
+ 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => false,
+ );
+
+ $columns['field10_year'] = array(
+ 'ColumnName' => '`field10_year`',
+ 'ColumnSize' => 4,
+ 'ColumnIndex' => 11,
+ 'DbType' => 'year',
+ 'AllowNull' => false,
+ 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => false,
+ );
+
+ $columns['field11_enum'] = array(
+ 'ColumnName' => '`field11_enum`',
+ 'ColumnSize' => null,
+ 'ColumnIndex' => 12,
+ 'DbType' => 'enum',
+ 'AllowNull' => false,
+ 'DefaultValue' => 'one',
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => false,
+ 'DbTypeValues' => array('one', 'two', 'three'),
+ );
+
+ $columns['field12_SET'] = array(
+ 'ColumnName' => '`field12_SET`',
+ 'ColumnSize' => null,
+ 'ColumnIndex' => 13,
+ 'DbType' => 'set',
+ 'AllowNull' => false,
+ 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => false,
+ 'DbTypeValues' => array('blue', 'red', 'green'),
+ );
+
+ $this->assertColumn($columns, $table);
+
+ $this->assertNull($table->getSchemaName());
+ $this->assertEqual('table1', $table->getTableName());
+ $this->assertEqual(array('id', 'name'), $table->getPrimaryKeys());
+ }
+
+ function assertColumn($columns, $table)
+ {
+ foreach($columns as $id=>$asserts)
+ {
+ $column = $table->Columns[$id];
+ foreach($asserts as $property=>$assert)
+ {
+ $ofAssert= var_export($assert,true);
+ $value = $column->{$property};
+ $ofValue = var_export($value, true);
+ $this->assertEqual($value, $assert,
+ "Column [{$id}] {$property} value {$ofValue} did not match {$ofAssert}");
+ }
+ }
+ }
+}
diff --git a/tests/unit/Data/DbCommon/PgsqlColumnTest.php b/tests/unit/Data/DbCommon/PgsqlColumnTest.php
new file mode 100644
index 00000000..7d7f1177
--- /dev/null
+++ b/tests/unit/Data/DbCommon/PgsqlColumnTest.php
@@ -0,0 +1,141 @@
+<?php
+
+Prado::using('System.Data.*');
+Prado::using('System.Data.Common.Pgsql.TPgsqlMetaData');
+
+/**
+ * @package System.Data.DbCommon
+ */
+class PgsqlColumnTest extends PHPUnit_Framework_TestCase
+{
+ function create_meta_data()
+ {
+ $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test');
+ return new TPgsqlMetaData($conn);
+ }
+
+ function test_text_column_def()
+ {
+ $table = $this->create_meta_data()->getTableInfo('public.address');
+ $this->assertEqual(count($table->getColumns()), 14);
+
+ $columns['id'] = array(
+ 'ColumnName' => '"id"',
+ 'ColumnSize' => null,
+ 'ColumnIndex' => 0,
+ 'DbType' => 'integer',
+ 'AllowNull' => false,
+ 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => true,
+ 'IsForeignKey' => false,
+ 'SequenceName' => 'public.address_id_seq',
+ );
+
+ $columns['username'] = array(
+ 'ColumnName' => '"username"',
+ 'ColumnSize' => 128,
+ 'ColumnIndex' => 1,
+ 'DbType' => 'character varying',
+ 'AllowNull' => false,
+ 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ );
+
+ $columns['phone'] = array(
+ 'ColumnName' => '"phone"',
+ 'ColumnSize' => 40,
+ 'ColumnIndex' => 2,
+ 'DbType' => 'character',
+ 'AllowNull' => false,
+ 'DefaultValue' => "'hello'::bpchar",
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ );
+
+ $columns['field1_boolean'] = array(
+ 'ColumnName' => '"field1_boolean"',
+ 'ColumnSize' => null,
+ 'ColumnIndex' => 3,
+ 'DbType' => 'boolean',
+ 'AllowNull' => false,
+ 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ );
+
+ $columns['field4_integer'] = array(
+ 'ColumnName' => '"field4_integer"',
+ 'ColumnSize' => null,
+ 'ColumnIndex' => 6,
+ 'DbType' => 'integer',
+ 'AllowNull' => false,
+ 'DefaultValue' => "1",
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => true,
+ 'SequenceName' => null,
+ );
+
+ $columns['field7_timestamp'] = array(
+ 'ColumnName' => '"field7_timestamp"',
+ 'ColumnSize' => 2,
+ 'ColumnIndex' => 9,
+ 'DbType' => 'timestamp without time zone',
+ 'AllowNull' => false,
+ 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
+ 'NumericPrecision' => 6,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ );
+
+ $columns['field9_numeric'] = array(
+ 'ColumnName' => '"field9_numeric"',
+ 'ColumnSize' => 393220,
+ 'ColumnIndex' => 11,
+ 'DbType' => 'numeric',
+ 'AllowNull' => false,
+ 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
+ 'NumericPrecision' => 6,
+ 'NumericScale' => 4,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ );
+ $this->assertColumn($columns, $table);
+
+ $this->assertEqual('public', $table->getSchemaName());
+ $this->assertEqual('address', $table->getTableName());
+ $this->assertEqual(array('id'), $table->getPrimaryKeys());
+ }
+
+ function assertColumn($columns, $table)
+ {
+ foreach($columns as $id=>$asserts)
+ {
+ $column = $table->Columns[$id];
+ foreach($asserts as $property=>$assert)
+ {
+ $ofAssert= var_export($assert,true);
+ $value = $column->{$property};
+ $ofValue = var_export($value, true);
+ $this->assertEqual($value, $assert,
+ "Column [{$id}] {$property} value {$ofValue} did not match {$ofAssert}");
+ }
+ }
+ }
+}
diff --git a/tests/unit/Data/DbCommon/SqliteColumnTest.php b/tests/unit/Data/DbCommon/SqliteColumnTest.php
new file mode 100644
index 00000000..88117e9e
--- /dev/null
+++ b/tests/unit/Data/DbCommon/SqliteColumnTest.php
@@ -0,0 +1,32 @@
+<?php
+Prado::using('System.Data.*');
+Prado::using('System.Data.Common.Sqlite.TSqliteMetaData');
+Prado::using('System.Data.DataGateway.TTableGateway');
+
+/**
+ * @package System.Data.DbCommon
+ */
+class SqliteColumnTest extends PHPUnit_Framework_TestCase
+{
+ /**
+ * @return TSqliteMetaData
+ */
+ function meta_data()
+ {
+ $conn = new TDbConnection('sqlite:c:/test.db');
+ return new TSqliteMetaData($conn);
+ }
+
+ function test_it()
+ {
+ //$table = $this->meta_data()->getTableInfo('foo');
+ //var_dump($table);
+ }
+
+ function test_table()
+ {
+ $conn = new TDbConnection('sqlite:c:/test.db');
+ //$table = new TTableGateway('Accounts', $conn);
+// var_dump($table->findAll()->readAll());
+ }
+} \ No newline at end of file
diff --git a/tests/unit/Data/SqlMap/ActiveRecordSqlMapTest.php b/tests/unit/Data/SqlMap/ActiveRecordSqlMapTest.php
new file mode 100644
index 00000000..c2eef7a1
--- /dev/null
+++ b/tests/unit/Data/SqlMap/ActiveRecordSqlMapTest.php
@@ -0,0 +1,88 @@
+<?php
+
+require_once(dirname(__FILE__).'/BaseCase.php');
+
+Prado::using('System.Data.ActiveRecord.TActiveRecord');
+
+/**
+ * @package System.Data.SqlMap
+ */
+class ActiveAccount extends TActiveRecord
+{
+ public $Account_Id;
+ public $Account_FirstName;
+ public $Account_LastName;
+ public $Account_Email;
+
+ public $Account_Banner_Option;
+ public $Account_Cart_Option;
+
+ const TABLE='Accounts';
+
+ public static function finder($className=__CLASS__)
+ {
+ return parent::finder($className);
+ }
+}
+
+class ActiveRecordSqlMapTest extends BaseCase
+{
+ function __construct()
+ {
+ parent::__construct();
+ $this->initSqlMap();
+ TActiveRecordManager::getInstance()->setDbConnection($this->getConnection());
+
+ //$this->initScript('account-init.sql');
+ }
+
+ function testLoadWithSqlMap()
+ {
+ $records = $this->sqlmap->queryForList('GetActiveRecordAccounts');
+ $registry=TActiveRecordManager::getInstance()->getObjectStateRegistry();
+ foreach($records as $record)
+ {
+ $this->assertEqual(get_class($record), 'ActiveAccount');
+ $this->assertTrue($registry->isCleanObject($record));
+ }
+ }
+
+ function testLoadWithActiveRecord()
+ {
+ $records = ActiveAccount::finder()->findAll();
+ $registry=TActiveRecordManager::getInstance()->getObjectStateRegistry();
+ foreach($records as $record)
+ {
+ $this->assertEqual(get_class($record), 'ActiveAccount');
+ //$this->assertTrue($registry->isCleanObject($record)); //? not clean anymore?
+ }
+ }
+
+ function testLoadWithSqlMap_SaveWithActiveRecord()
+ {
+ $record = $this->sqlmap->queryForObject('GetActiveRecordAccounts');
+ $registry=TActiveRecordManager::getInstance()->getObjectStateRegistry();
+ $record->Account_FirstName = "Testing 123";
+ $this->assertTrue($registry->isDirtyObject($record));
+
+ $this->assertTrue($record->save());
+
+ $check1 = $this->sqlmap->queryForObject('GetActiveRecordAccounts');
+ $finder = ActiveAccount::finder();
+ $check2 = $finder->findByAccount_FirstName($record->Account_FirstName);
+
+
+ $this->assertSameAccount($record,$check1);
+ $this->assertSameAccount($record,$check2);
+
+ $this->initScript('account-init.sql');
+ }
+
+ function assertSameAccount($account1,$account2)
+ {
+ $props = array('Account_Id', 'Account_FirstName', 'Account_LastName',
+ 'Account_Email', 'Account_Banner_Option', 'Account_Cart_Option');
+ foreach($props as $prop)
+ $this->assertEqual($account1->{$prop}, $account2->{$prop});
+ }
+}
diff --git a/tests/unit/Data/SqlMap/AllTests.php b/tests/unit/Data/SqlMap/AllTests.php
deleted file mode 100644
index 08870eb3..00000000
--- a/tests/unit/Data/SqlMap/AllTests.php
+++ /dev/null
@@ -1,29 +0,0 @@
-<?php
-
-
-if(!defined('PHPUnit_MAIN_METHOD')) {
- define('PHPUnit_MAIN_METHOD', 'Data_SqlMap_AllTests::main');
-}
-
-require_once 'DynamicParameterTest.php';
-require_once 'DataMapper/AllTests.php';
-
-class Data_SqlMap_AllTests {
-
- public static function main() {
- PHPUnit_TextUI_TestRunner::run(self::suite());
- }
-
- public static function suite() {
- $suite = new PHPUnit_Framework_TestSuite('System.Data.SqlMap');
-
- $suite->addTestSuite('DynamicParameterTest');
- $suite -> addTest( Data_SqlMap_DataMapper_AllTests::suite() );
-
- return $suite;
- }
-}
-
-if(PHPUnit_MAIN_METHOD == 'Data_SqlMap_AllTests::main') {
- Data_SqlMap_AllTests::main();
-}
diff --git a/tests/unit/Data/SqlMap/BaseCase.php b/tests/unit/Data/SqlMap/BaseCase.php
new file mode 100644
index 00000000..15bb3367
--- /dev/null
+++ b/tests/unit/Data/SqlMap/BaseCase.php
@@ -0,0 +1,260 @@
+<?php
+
+require_once(dirname(__FILE__).'/common.php');
+Prado::using('System.Data.SqlMap.TSqlMapManager');
+
+/**
+ * @package System.Data.SqlMap
+ */
+class BaseCase extends PHPUnit_Framework_TestCase
+{
+ protected $sqlmap;
+ protected $connection;
+ private $mapper;
+ private $config;
+ protected $ScriptDirectory;
+
+ public function testCase1()
+ {
+ $this->assertTrue(true);
+ }
+
+ public function testCase2()
+ {
+ $this->assertTrue(true);
+ }
+
+ public function __construct()
+ {
+ parent::__construct();
+ $this->config = BaseTestConfig::createConfigInstance();
+ $this->ScriptDirectory = $this->config->getScriptDir();
+ }
+
+ public function hasSupportFor($feature)
+ {
+ return $this->config->hasFeature($feature);
+ }
+
+ public function __destruct()
+ {
+ if(!is_null($this->mapper))
+ $this->mapper->cacheConfiguration();
+ }
+
+ function getConnection()
+ {
+ if(is_null($this->connection))
+ $this->connection = $this->config->getConnection();
+ $this->connection->setActive(true);
+ return $this->connection;
+ }
+
+ /**
+ * Initialize an sqlMap
+ */
+ protected function initSqlMap()
+ {
+ $manager = new TSqlMapManager($this->config->getConnection());
+ $manager->configureXml($this->config->getSqlMapConfigFile());
+ $this->sqlmap = $manager->getSqlMapGateway();
+ $manager->TypeHandlers->registerTypeHandler(new TDateTimeHandler);
+ }
+
+ /**
+ * Run a sql batch for the datasource.
+ */
+ protected function initScript($script)
+ {
+ $runner = $this->config->getScriptRunner();
+ $runner->runScript($this->getConnection(), $this->ScriptDirectory.$script);
+ }
+
+ /**
+ * Create a new account with id = 6
+ */
+ protected function NewAccount6()
+ {
+ $account = new Account();
+ $account->setID(6);
+ $account->setFirstName('Calamity');
+ $account->setLastName('Jane');
+ $account->setEmailAddress('no_email@provided.com');
+ return $account;
+ }
+
+ /**
+ * Verify that the input account is equal to the account(id=1).
+ */
+ protected function assertAccount1(Account $account)
+ {
+ $this->assertIdentical($account->getID(), 1);
+ $this->assertIdentical($account->getFirstName(), 'Joe');
+ $this->assertIdentical($account->getEmailAddress(), 'Joe.Dalton@somewhere.com');
+ }
+
+ /**
+ * Verify that the input account is equal to the account(id=6).
+ */
+ protected function assertAccount6(Account $account)
+ {
+ $this->assertIdentical($account->getID(), 6);
+ $this->assertIdentical($account->getFirstName(), 'Calamity');
+ $this->assertIdentical($account->getLastName(), 'Jane');
+ $this->assertNull($account->getEmailAddress());
+ }
+
+ /**
+ * Verify that the input order is equal to the order(id=1).
+ */
+ protected function assertOrder1(Order $order)
+ {
+ $date = @mktime(8,15,0,2,15,2003);
+
+ $this->assertIdentical((int)$order->getID(), 1);
+ if($order->getDate() instanceof TDateTime)
+ $this->assertIdentical($order->getDate()->getTimestamp(), $date);
+ else
+ $this->fail();
+ $this->assertIdentical($order->getCardType(), 'VISA');
+ $this->assertIdentical($order->getCardNumber(), '999999999999');
+ $this->assertIdentical($order->getCardExpiry(), '05/03');
+ $this->assertIdentical($order->getStreet(), '11 This Street');
+ $this->assertIdentical($order->getProvince(), 'BC');
+ $this->assertIdentical($order->getPostalCode(), 'C4B 4F4');
+ }
+
+ function assertAccount1AsHashArray($account)
+ {
+ $this->assertIdentical(1, (int)$account["Id"]);
+ $this->assertIdentical("Joe", $account["FirstName"]);
+ $this->assertIdentical("Dalton", $account["LastName"]);
+ $this->assertIdentical("Joe.Dalton@somewhere.com", $account["EmailAddress"]);
+ }
+
+ function AssertOrder1AsHashArray($order)
+ {
+ $date = @mktime(8,15,0,2,15,2003);
+
+ $this->assertIdentical(1, $order["Id"]);
+ if($order['Date'] instanceof TDateTime)
+ $this->assertIdentical($date, $order["Date"]->getTimestamp());
+ else
+ $this->fail();
+ $this->assertIdentical("VISA", $order["CardType"]);
+ $this->assertIdentical("999999999999", $order["CardNumber"]);
+ $this->assertIdentical("05/03", $order["CardExpiry"]);
+ $this->assertIdentical("11 This Street", $order["Street"]);
+ $this->assertIdentical("Victoria", $order["City"]);
+ $this->assertIdentical("BC", $order["Province"]);
+ $this->assertIdentical("C4B 4F4", $order["PostalCode"]);
+ }
+
+}
+
+class HundredsBool extends TSqlMapTypeHandler
+{
+ public function getResult($string)
+ {
+ $value = intval($string);
+ if($value == 100)
+ return true;
+ if($value == 200)
+ return false;
+ //throw new Exception('unexpected value '.$value);
+ }
+
+ public function getParameter($parameter)
+ {
+ if($parameter)
+ return 100;
+ else
+ return 200;
+ }
+
+ public function createNewInstance($data=null)
+ {
+ throw new TDataMapperException('can not create');
+ }
+}
+
+class OuiNonBool extends TSqlMapTypeHandler
+{
+ const YES = "Oui";
+ const NO = "Non";
+
+ public function getResult($string)
+ {
+ if($string === self::YES)
+ return true;
+ if($string === self::NO)
+ return false;
+ //throw new Exception('unexpected value '.$string);
+ }
+
+ public function getParameter($parameter)
+ {
+ if($parameter)
+ return self::YES;
+ else
+ return self::NO;
+ }
+
+ public function createNewInstance($data=null)
+ {
+ throw new TDataMapperException('can not create');
+ }
+}
+
+class TDateTimeHandler extends TSqlMapTypeHandler
+{
+ public function getType()
+ {
+ return 'date';
+ }
+
+ public function getResult($string)
+ {
+ $time = new TDateTime($string);
+ return $time;
+ }
+
+ public function getParameter($parameter)
+ {
+ if($parameter instanceof TDateTime)
+ return $parameter->getTimestamp();
+ else
+ return $parameter;
+ }
+
+ public function createNewInstance($data=null)
+ {
+ return new TDateTime;
+ }
+}
+
+class TDateTime
+{
+ private $_datetime;
+
+ public function __construct($datetime=null)
+ {
+ if(!is_null($datetime))
+ $this->setDatetime($datetime);
+ }
+
+ public function getTimestamp()
+ {
+ return strtotime($this->getDatetime());
+ }
+
+ public function getDateTime()
+ {
+ return $this->_datetime;
+ }
+
+ public function setDateTime($value)
+ {
+ $this->_datetime = $value;
+ }
+}
diff --git a/tests/unit/Data/SqlMap/CacheTest.php b/tests/unit/Data/SqlMap/CacheTest.php
new file mode 100644
index 00000000..3d2ccd41
--- /dev/null
+++ b/tests/unit/Data/SqlMap/CacheTest.php
@@ -0,0 +1,162 @@
+<?php
+
+require_once(dirname(__FILE__).'/BaseCase.php');
+
+/**
+ * @package System.Data.SqlMap
+ */
+class CacheTest extends BaseCase
+{
+ function __construct()
+ {
+ parent::__construct();
+
+ $this->initSqlMap();
+
+ //force autoload
+ new Account;
+ }
+
+ function resetDatabase()
+ {
+ $this->initScript('account-init.sql');
+ }
+
+ /**
+ * Test for JIRA 29
+ */
+ function testJIRA28()
+ {
+ $account = $this->sqlmap->queryForObject("GetNoAccountWithCache",-99);
+ $this->assertNull($account);
+ }
+
+ /**
+ * Test Cache query
+ */
+ function testQueryWithCache()
+ {
+ $this->resetDatabase();
+
+ $list1 = $this->sqlmap->queryForList("GetCachedAccountsViaResultMap");
+
+ $list2 = $this->sqlmap->queryForList("GetCachedAccountsViaResultMap");
+
+ $this->assertTrue($list1 === $list2);
+
+ $account = $list1[1];
+ $account->setEmailAddress("somebody@cache.com");
+
+ //this will cause the cache to flush
+ $this->sqlmap->update("UpdateAccountViaInlineParameters", $account);
+
+ $list3 = $this->sqlmap->queryForList("GetCachedAccountsViaResultMap");
+
+ $this->assertTrue($list1 !== $list3);
+
+ $this->resetDatabase();
+ }
+
+
+ /**
+ * Test flush Cache
+ */
+ function testFlushDataCache()
+ {
+ $list1 = $this->sqlmap->queryForList("GetCachedAccountsViaResultMap");
+ $list2 = $this->sqlmap->queryForList("GetCachedAccountsViaResultMap");
+
+ $this->assertTrue($list1 === $list2);
+ $this->sqlmap->flushCaches();
+
+ $list3 = $this->sqlmap->queryForList("GetCachedAccountsViaResultMap");
+
+ $this->assertTrue($list1 !== $list3);
+ }
+
+ /**
+ *
+ */
+ function testFlushDataCacheOnExecute()
+ {
+ $list1 = $this->sqlmap->queryForList("GetCachedAccountsViaResultMap");
+
+ $list2 = $this->sqlmap->queryForList("GetCachedAccountsViaResultMap");
+
+ $this->assertTrue($list1 === $list2);
+ $this->sqlmap->update("UpdateAccountViaInlineParameters", $list1[0]);
+
+ $list3 = $this->sqlmap->queryForList("GetCachedAccountsViaResultMap");
+
+ $this->assertTrue($list1 !== $list3);
+ }
+
+ /**
+ */
+ protected function getCacheModel()
+ {
+ $cache = new TSqlMapCacheModel();
+ // $cache->setFlushInterval(5*60);
+ $cache->setImplementation('LRU');
+ $cache->initialize();
+ return $cache;
+ }
+
+ /**
+ * Test CacheHit
+ */
+ function testCacheHit()
+ {
+ $cache = $this->getCacheModel();
+ $key = new TSqlMapCacheKey('testkey');
+ $cache->set($key, 'a');
+
+ $returnedObject = $cache->get($key);
+
+ $this->assertIdentical('a', $returnedObject);
+
+ $this->assertIdentical(1, $cache->getHitRatio());
+ }
+
+
+
+ /**
+ * Test CacheMiss
+ */
+ function testCacheMiss()
+ {
+ $cache = $this->getCacheModel();
+ $key = new TSqlMapCacheKey('testKey');
+ $value = 'testValue';
+ $cache->set($key, $value);
+
+ $wrongKey = new TSqlMapCacheKey('wrongKey');
+
+ $returnedObject = $cache->get($wrongKey);
+ $this->assertNotEqual($value, $returnedObject);
+ $this->assertNull($returnedObject) ;
+ $this->assertIdentical(0, $cache->getHitRatio());
+ }
+
+ /**
+ * Test CacheHitMiss
+ */
+ function testCacheHitMiss()
+ {
+ $cache = $this->getCacheModel();
+ $key = new TSqlMapCacheKey('testKey');
+
+ $value = "testValue";
+ $cache->set($key, $value);
+
+ $returnedObject = $cache->get($key);
+ $this->assertIdentical($value, $returnedObject);
+
+ $wrongKey = new TSqlMapCacheKey('wrongKey');
+
+ $returnedObject = $cache->get($wrongKey);
+ $this->assertNotEqual($value, $returnedObject);
+ $this->assertNull($returnedObject) ;
+ $this->assertIdentical(0.5, $cache->getHitRatio());
+ }
+}
diff --git a/tests/unit/Data/SqlMap/DataMapper/AllTests.php b/tests/unit/Data/SqlMap/DataMapper/AllTests.php
deleted file mode 100644
index d685d474..00000000
--- a/tests/unit/Data/SqlMap/DataMapper/AllTests.php
+++ /dev/null
@@ -1,27 +0,0 @@
-<?php
-
-
-if(!defined('PHPUnit_MAIN_METHOD')) {
- define('PHPUnit_MAIN_METHOD', 'Data_SqlMap_DataMapper_AllTests::main');
-}
-
-require_once 'TPropertyAccessTest.php';
-
-class Data_SqlMap_DataMapper_AllTests {
-
- public static function main() {
- PHPUnit_TextUI_TestRunner::run(self::suite());
- }
-
- public static function suite() {
- $suite = new PHPUnit_Framework_TestSuite('System.Data.SqlMap.DataMapper');
-
- $suite->addTestSuite('TPropertyAccessTest');
-
- return $suite;
- }
-}
-
-if(PHPUnit_MAIN_METHOD == 'Data_SqlMap_DataMapper_AllTests::main') {
- Data_SqlMap_DataMapper_AllTests::main();
-} \ No newline at end of file
diff --git a/tests/unit/Data/SqlMap/DelegateTest.php b/tests/unit/Data/SqlMap/DelegateTest.php
new file mode 100644
index 00000000..5bfbe5ce
--- /dev/null
+++ b/tests/unit/Data/SqlMap/DelegateTest.php
@@ -0,0 +1,62 @@
+<?php
+require_once(dirname(__FILE__).'/BaseCase.php');
+
+/**
+ * @package System.Data.SqlMap
+ */
+class DelegateTest extends BaseCase
+{
+ function __construct()
+ {
+ parent::__construct();
+ $this->initSqlMap();
+ }
+
+ function testListDelegate()
+ {
+ $list = $this->sqlmap->queryWithRowDelegate(
+ "GetAllAccountsViaResultMap", array($this, 'listHandler'));
+
+ $this->assertIdentical(5, count($list));
+ $this->assertAccount1($list[0]);
+ $this->assertIdentical(1, $list[0]->getID());
+ $this->assertIdentical(2, $list[1]->getID());
+ $this->assertIdentical(3, $list[2]->getID());
+ $this->assertIdentical(4, $list[3]->getID());
+ $this->assertIdentical(5, $list[4]->getID());
+ }
+
+ /**
+ * Test ExecuteQueryForMap : Hashtable.
+ */
+ function testExecuteQueryForMap()
+ {
+ $map = $this->sqlmap->QueryForMapWithRowDelegate(
+ "GetAllAccountsViaResultClass", array($this, 'mapHandler'), null, "FirstName");
+
+ $this->assertIdentical(5, count($map));
+ $this->assertAccount1($map["Joe"]);
+
+ $this->assertIdentical(1, $map["Joe"]->getID());
+ $this->assertIdentical(2, $map["Averel"]->getID());
+ $this->assertIdentical(3, $map["William"]->getID());
+ $this->assertIdentical(4, $map["Jack"]->getID());
+ $this->assertIdentical(5, $map["Gilles"]->getID());
+ }
+
+ public function listHandler($sender, $param)
+ {
+ $list = &$param->getList();
+ $list[] = $param->result;
+ $this->assertTrue($param->result instanceof Account);
+ }
+
+ public function mapHandler($sender, $param)
+ {
+ $map = &$param->getMap();
+ $map[$param->getKey()] = $param->getValue();
+ $this->assertTrue($param->getValue() instanceof Account);
+ }
+}
+
+
diff --git a/tests/unit/Data/SqlMap/GroupByTest.php b/tests/unit/Data/SqlMap/GroupByTest.php
new file mode 100644
index 00000000..3d414922
--- /dev/null
+++ b/tests/unit/Data/SqlMap/GroupByTest.php
@@ -0,0 +1,41 @@
+<?php
+require_once(dirname(__FILE__).'/BaseCase.php');
+
+/**
+ * @package System.Data.SqlMap
+ */
+class AccountWithOrders extends Account
+{
+ private $_orders = array();
+
+ public function setOrders($orders)
+ {
+ $this->_orders = $orders;
+ }
+
+ public function getOrders()
+ {
+ return $this->_orders;
+ }
+}
+
+
+class GroupByTest extends BaseCase
+{
+ function __construct()
+ {
+ parent::__construct();
+ $this->initSqlMap();
+ }
+
+ function testAccountWithOrders()
+ {
+ $this->initScript('account-init.sql');
+ $accounts = $this->sqlmap->queryForList("getAccountWithOrders");
+ $this->assertIdentical(5, count($accounts));
+ foreach($accounts as $account)
+ $this->assertIdentical(2, count($account->getOrders()));
+ }
+
+/**/
+}
diff --git a/tests/unit/Data/SqlMap/InheritanceTest.php b/tests/unit/Data/SqlMap/InheritanceTest.php
new file mode 100644
index 00000000..9c8a805e
--- /dev/null
+++ b/tests/unit/Data/SqlMap/InheritanceTest.php
@@ -0,0 +1,144 @@
+<?php
+
+require_once(dirname(__FILE__).'/BaseCase.php');
+
+/**
+ * @package System.Data.SqlMap
+ */
+class InheritanceTest extends BaseCase
+{
+ function __construct()
+ {
+ parent::__construct();
+
+ $this->initSqlMap();
+ $this->initScript('documents-init.sql');
+ }
+
+ /// Test All document with no formula
+ function testGetAllDocument()
+ {
+ $list = $this->sqlmap->queryForList("GetAllDocument");
+
+ $this->assertEqual(6, count($list));
+ $book = $list[0];
+ $this->assertBook($book, 1, "The World of Null-A", 55);
+
+ $book = $list[1];
+ $this->assertBook($book, 3, "Lord of the Rings", 3587);
+
+ $document = $list[2];
+ $this->assertDocument($document, 5, "Le Monde");
+
+ $document = $list[3];
+ $this->assertDocument($document, 6, "Foundation");
+
+ $news = $list[4];
+ $this->assertNewspaper($news, 2, "Le Progres de Lyon", "Lyon");
+
+ $document = $list[5];
+ $this->assertDocument($document, 4, "Le Canard enchaine");
+ }
+
+ /// Test All document in a typed collection
+ function testGetTypedCollection()
+ {
+ $list = $this->sqlmap->queryForList("GetTypedCollection");
+
+ $this->assertEqual(6, $list->getCount());
+
+ $book = $list[0];
+ $this->assertBook($book, 1, "The World of Null-A", 55);
+
+ $book = $list[1];
+ $this->assertBook($book, 3, "Lord of the Rings", 3587);
+
+ $document = $list[2];
+ $this->assertDocument($document, 5, "Le Monde");
+
+ $document = $list[3];
+ $this->assertDocument($document, 6, "Foundation");
+
+ $news = $list[4];
+ $this->assertNewspaper($news, 2, "Le Progres de Lyon", "Lyon");
+
+ $document = $list[5];
+ $this->assertDocument($document, 4, "Le Canard enchaine");
+ }
+
+ /// Test All document with Custom Type Handler
+ function testGetAllDocumentWithCustomTypeHandler()
+ {
+
+ //register the custom inheritance type handler
+ $this->sqlmap->registerTypeHandler(new CustomInheritance);
+
+ $list = $this->sqlmap->queryForList("GetAllDocumentWithCustomTypeHandler");
+
+ $this->assertEqual(6, count($list));
+ $book = $list[0];
+ $this->assertBook($book, 1, "The World of Null-A", 55);
+
+ $book = $list[1];
+ $this->assertBook($book, 3, "Lord of the Rings", 3587);
+
+ $news = $list[2];
+ $this->assertNewspaper($news, 5, "Le Monde", "Paris");
+
+ $book = $list[3];
+ $this->assertBook($book, 6, "Foundation", 557);
+
+ $news = $list[4];
+ $this->assertNewspaper($news, 2, "Le Progres de Lyon", "Lyon");
+
+ $news = $list[5];
+ $this->assertNewspaper($news, 4, "Le Canard enchaine", "Paris");
+ }
+
+ function AssertDocument(Document $document, $id, $title)
+ {
+ $this->assertEqual($id, $document->getID());
+ $this->assertEqual($title, $document->getTitle());
+ }
+
+ function AssertBook(Book $book, $id, $title, $pageNumber)
+ {
+ $this->assertEqual($id, $book->getId());
+ $this->assertEqual($title, $book->getTitle());
+ $this->assertEqual($pageNumber, (int)$book->getPageNumber());
+ }
+
+ function AssertNewspaper(Newspaper $news, $id, $title, $city)
+ {
+ $this->assertEqual($id, $news->getId());
+ $this->assertEqual($title, $news->getTitle());
+ $this->assertEqual($city, $news->getCity());
+ }
+}
+
+
+class CustomInheritance extends TSqlMapTypeHandler
+{
+ public function getResult($type)
+ {
+ switch ($type)
+ {
+ case 'Monograph': case 'Book':
+ return 'Book';
+ case 'Tabloid': case 'Broadsheet': case 'Newspaper':
+ return 'Newspaper';
+ default:
+ return 'Document';
+ }
+ }
+
+ public function getParameter($parameter)
+ {
+ throw new TDataMapperException('not implemented');
+ }
+
+ public function createNewInstance($data=null)
+ {
+ throw new TDataMapperException('can not create');
+ }
+} \ No newline at end of file
diff --git a/tests/unit/Data/SqlMap/ParameterMapTest.php b/tests/unit/Data/SqlMap/ParameterMapTest.php
new file mode 100644
index 00000000..de5c235c
--- /dev/null
+++ b/tests/unit/Data/SqlMap/ParameterMapTest.php
@@ -0,0 +1,247 @@
+<?php
+
+require_once(dirname(__FILE__).'/BaseCase.php');
+
+/**
+ * @package System.Data.SqlMap
+ */
+class ParameterMapTest extends BaseCase
+{
+ function __construct()
+ {
+ parent::__construct();
+ $this->initSqlMap();
+ }
+
+ function setup()
+ {
+ $this->initScript('account-init.sql');
+// $this->initScript('account-procedure.sql');
+ $this->initScript('order-init.sql');
+// $this->initScript('line-item-init.sql');
+ $this->initScript('category-init.sql');
+ }
+
+ /// Test null replacement in ParameterMap property
+ function testNullValueReplacement()
+ {
+ $account = $this->newAccount6();
+
+ $this->sqlmap->insert("InsertAccountViaParameterMap", $account);
+ $account = $this->sqlmap->queryForObject("GetAccountNullableEmail", 6);
+
+ $this->assertNull($account->getEmailAddress(), 'no_email@provided.com');
+
+ $this->assertAccount6($account);
+ }
+
+ /// Test Test Null Value Replacement Inline
+ function testNullValueReplacementInline()
+ {
+ $account = $this->newAccount6();
+
+ $this->sqlmap->insert("InsertAccountViaInlineParameters", $account);
+ $account = $this->sqlmap->queryForObject("GetAccountNullableEmail", 6);
+ $this->assertNull($account->getEmailAddress());
+
+ $this->assertAccount6($account);
+ }
+
+ /// Test Test Null Value Replacement Inline
+ function testSpecifiedType()
+ {
+ $account = $this->newAccount6();
+ $account->setEmailAddress(null);
+ $this->sqlmap->insert("InsertAccountNullableEmail", $account);
+ $account = $this->sqlmap->queryForObject("GetAccountNullableEmail", 6);
+ $this->assertAccount6($account);
+ }
+
+
+ /// Test Test Null Value Replacement Inline
+ function testUnknownParameterClass()
+ {
+ $account = $this->newAccount6();
+ $account->setEmailAddress(null);
+ $this->sqlmap->insert("InsertAccountUknownParameterClass", $account);
+ $account = $this->sqlmap->queryForObject("GetAccountNullableEmail", 6);
+ $this->assertAccount6($account);
+ }
+
+
+ /// Test null replacement in ParameterMap property
+ /// for System.DateTime.MinValue
+ function testNullValueReplacementForDateTimeMinValue()
+ {
+ $account = $this->newAccount6();
+ $this->sqlmap->insert("InsertAccountViaParameterMap", $account);
+ $order = new Order();
+ $order->setId(99);
+ $order->setCardExpiry("09/11");
+ $order->setAccount($account);
+ $order->setCardNumber("154564656");
+ $order->setCardType("Visa");
+ $order->setCity("Lyon");
+ $order->setDate(null);
+ $order->setPostalCode("69004");
+ $order->setProvince("Rhone");
+ $order->setStreet("rue Durand");
+
+ $this->sqlmap->insert("InsertOrderViaParameterMap", $order);
+
+ $orderTest = $this->sqlmap->queryForObject("GetOrderLiteByColumnName", 99);
+
+ $this->assertIdentical($order->getCity(), $orderTest->getCity());
+ }
+
+ /// Test null replacement in ParameterMap/Hahstable property
+ /// for System.DateTime.MinValue
+ function testNullValueReplacementForDateTimeWithHashtable()
+ {
+ $account = $this->newAccount6();
+
+ $this->sqlmap->insert("InsertAccountViaParameterMap", $account);
+
+ $order = new Order();
+ $order->setId(99);
+ $order->setCardExpiry("09/11");
+ $order->setAccount($account);
+ $order->setCardNumber("154564656");
+ $order->setCardType("Visa");
+ $order->setCity("Lyon");
+ $order->setDate('0001-01-01 00:00:00'); //<-- null replacement
+ $order->setPostalCode("69004");
+ $order->setProvince("Rhone");
+ $order->setStreet("rue Durand");
+
+ $this->sqlmap->insert("InsertOrderViaParameterMap", $order);
+
+ $orderTest = $this->sqlmap->queryForObject("GetOrderByHashTable", 99);
+
+ $this->assertIdentical($orderTest["Date"], '0001-01-01 00:00:00');
+ }
+
+ /// Test null replacement in ParameterMap property
+ /// for Guid
+ function testNullValueReplacementForGuidValue()
+ {
+ if($this->hasSupportFor('last_insert_id'))
+ {
+ $category = new Category();
+ $category->setName("Totoasdasd");
+ $category->setGuidString('00000000-0000-0000-0000-000000000000');
+
+ $key = $this->sqlmap->insert("InsertCategoryNull", $category);
+
+ $categoryRead = $this->sqlmap->queryForObject("GetCategory", $key);
+
+ $this->assertIdentical($category->getName(), $categoryRead->getName());
+ $this->assertIdentical('', $categoryRead->getGuidString());
+ }
+ }
+
+
+
+/// Test complex mapping Via hasTable
+ /// <example>
+ ///
+ /// map.Add("Item", Item);
+ /// map.Add("Order", Order);
+ ///
+ /// <statement>
+ /// ... #Item.prop1#...#Order.prop2#
+ /// </statement>
+ ///
+ /// </example>
+ function testComplexMappingViaHasTable()
+ {
+ $a = new Account();
+ $a->setFirstName("Joe");
+
+ $param["Account"] = $a;
+
+ $o = new Order();
+ $o->setCity("Dalton");
+ $param["Order"] = $o;
+
+ $accountTest = $this->sqlmap->queryForObject("GetAccountComplexMapping", $param);
+
+ $this->assertAccount1($accountTest);
+ }
+
+/*
+ /// Test ByteArrayTypeHandler via Picture Property
+ function testByteArrayTypeHandler()
+ {
+ $account = $this->newAccount6();
+
+ $this->sqlmap->insert("InsertAccountViaParameterMap", $account);
+
+ $order = new Order();
+ $order->setId(99);
+ $order->setCardExpiry("09/11");
+ $order->setAccount($account);
+ $order->setCardNumber("154564656");
+ $order->setCardType("Visa");
+ $order->setCity("Lyon");
+ $order->setDate(0);
+ $order->setPostalCode("69004");
+ $order->setProvince("Rhone");
+ $order->setStreet("rue Durand");
+
+ $this->sqlmap->insert("InsertOrderViaParameterMap", $order);
+
+ $item = new LineItem();
+ $item->setId(99);
+ $item->setCode("test");
+ $item->setPrice(-99.99);
+ $item->setQuantity(99);
+ $item->setOrder($order);
+ $item->setPicture(null);
+
+ // Check insert
+ $this->sqlmap->insert("InsertLineItemWithPicture", $item);
+
+ // select
+ $item = null;
+
+ $param["LineItem_ID"] = 99;
+ $param["Order_ID"] = 99;
+
+ $item = $this->sqlmap->queryForObject("GetSpecificLineItemWithPicture", $param);
+
+ $this->assertNotNull($item->getId());
+// $this->assertNotNull($item->getPicture());
+// $this->assertIdentical( GetSize(item.Picture), this.GetSize( this.GetPicture() ));
+ }
+*/
+
+ /// Test extend parameter map capacity
+ /// (Support Requests 1043181)
+ function testInsertOrderViaExtendParameterMap()
+ {
+ $this->sqlmap->getSqlMapManager()->getTypeHandlers()->registerTypeHandler(new HundredsBool());
+
+ $account = $this->newAccount6();
+ $this->sqlmap->insert("InsertAccountViaParameterMap", $account);
+
+ $order = new Order();
+ $order->setId(99);
+ $order->setCardExpiry("09/11");
+ $order->setAccount($account);
+ $order->setCardNumber("154564656");
+ $order->setCardType("Visa");
+ $order->setCity("Lyon");
+ $order->setDate(null); //<-- null replacement
+ $order->setPostalCode("69004");
+ $order->setProvince("Rhone");
+ $order->setStreet("rue Durand");
+
+ $this->sqlmap->insert("InsertOrderViaExtendParameterMap", $order);
+
+ $orderTest = $this->sqlmap->queryForObject("GetOrderLiteByColumnName", 99);
+
+ $this->assertIdentical($order->getCity(), $orderTest->getCity());
+ }
+/**/
+}
diff --git a/tests/unit/Data/SqlMap/PropertyAccessTest.php b/tests/unit/Data/SqlMap/PropertyAccessTest.php
new file mode 100644
index 00000000..eb8306d5
--- /dev/null
+++ b/tests/unit/Data/SqlMap/PropertyAccessTest.php
@@ -0,0 +1,75 @@
+<?php
+
+require_once(dirname(__FILE__).'/BaseCase.php');
+
+/**
+ * @package System.Data.SqlMap
+ */
+class PropertyAccessTest extends BaseCase
+{
+ function testGetPublicProperty()
+ {
+ $account = new AccountBis();
+
+ $account->Id = 10;
+ $account->FirstName = "Luky";
+ $account->LastName = "Luke";
+ $account->EmailAddress = "luly.luke@somewhere.com";
+
+ $two = new AccountBis();
+ $two->Id = 12;
+ $two->FirstName = "Mini Me!";
+ $account->More = $two;
+
+ $account6 = $this->NewAccount6();
+ $two->More = $account6;
+
+ $this->assertIdentical(10, TPropertyAccess::get($account, 'Id'));
+ $this->assertIdentical(12, TPropertyAccess::get($account, 'More.Id'));
+ $this->assertIdentical(6, TPropertyAccess::get($account, 'More.More.Id'));
+ }
+
+ function testSetPublicProperty()
+ {
+ $account = new AccountBis();
+
+ $account->Id = 10;
+ $account->FirstName = "Luky";
+ $account->LastName = "Luke";
+ $account->EmailAddress = "luly.luke@somewhere.com";
+
+ $two = new AccountBis();
+ $two->Id = 12;
+ $two->FirstName = "Mini Me!";
+ TPropertyAccess::set($account, 'More', $two);
+
+ $account6 = $this->NewAccount6();
+ TPropertyAccess::set($account, 'More.More', $account6);
+
+ TPropertyAccess::set($account, 'More.More.EmailAddress', 'hahaha');
+
+ $this->assertIdentical(10, TPropertyAccess::get($account, 'Id'));
+ $this->assertIdentical(12, TPropertyAccess::get($account, 'More.Id'));
+ $this->assertIdentical(6, TPropertyAccess::get($account, 'More.More.Id'));
+
+ $this->assertIdentical('hahaha',
+ TPropertyAccess::get($account, 'More.More.EmailAddress'));
+ }
+
+ function testArrayAccessProperty()
+ {
+ $account = new AccountBis();
+ $things['more'] = 1;
+ $things['accounts'] = $this->NewAccount6();
+ $account->More = $things;
+
+ $this->assertIdentical(6, TPropertyAccess::get($account, 'More.accounts.ID'));
+
+ TPropertyAccess::set($account, 'More.accounts.EmailAddress', 'adssd');
+ $this->assertIdentical('adssd', TPropertyAccess::get($account, 'More.accounts.EmailAddress'));
+
+ $this->assertIdentical(1, TPropertyAccess::get($things, 'more'));
+ }
+
+}
+
diff --git a/tests/unit/Data/SqlMap/ResultClassTest.php b/tests/unit/Data/SqlMap/ResultClassTest.php
new file mode 100644
index 00000000..9b02ca70
--- /dev/null
+++ b/tests/unit/Data/SqlMap/ResultClassTest.php
@@ -0,0 +1,247 @@
+<?php
+require_once(dirname(__FILE__).'/BaseCase.php');
+
+/**
+ * @package System.Data.SqlMap
+ */
+class ResultClassTest extends BaseCase
+{
+ function __construct()
+ {
+ parent::__construct();
+ $this->initSqlMap();
+ }
+
+ /**
+ * Test a boolean resultClass
+ */
+ function testBoolean()
+ {
+ $bit = $this->sqlmap->queryForObject("GetBoolean", 1);
+ $this->assertIdentical(true, $bit);
+ }
+
+ /**
+ * Test a boolean implicit resultClass
+ */
+ function testBooleanWithoutResultClass()
+ {
+ $bit = (boolean)$this->sqlmap->queryForObject("GetBooleanWithoutResultClass", 1);
+ $this->assertIdentical(true, $bit);
+ }
+
+ /**
+ * Test a byte resultClass
+ */
+ function testByte()
+ {
+ $letter = $this->sqlmap->queryForObject("GetByte", 1);
+ $this->assertIdentical(155, (int)$letter);
+ }
+
+ /**
+ * Test a byte implicit resultClass
+ */
+ function testByteWithoutResultClass()
+ {
+ $letter = $this->sqlmap->queryForObject("GetByteWithoutResultClass", 1);
+ $this->assertIdentical(155, (int)$letter);
+ }
+
+ /**
+ * Test a char resultClass
+ */
+ function testChar()
+ {
+ $letter = $this->sqlmap->queryForObject("GetChar", 1);
+ $this->assertIdentical('a', trim($letter));
+ }
+
+ /**
+ * Test a char implicit resultClass
+ */
+ function testCharWithoutResultClass()
+ {
+ $letter = $this->sqlmap->queryForObject("GetCharWithoutResultClass", 1);
+ $this->assertIdentical('a', trim($letter));
+ }
+
+ /**
+ * Test a DateTime resultClass
+ */
+ function testDateTime()
+ {
+ $orderDate = $this->sqlmap->queryForObject("GetDate", 1);
+ $date = @mktime(8, 15, 00, 2, 15, 2003);
+ $this->assertIdentical($date, $orderDate->getTimeStamp());
+ }
+
+ /**
+ * Test a DateTime implicit resultClass
+ */
+ function testDateTimeWithoutResultClass()
+ {
+ $date = $this->sqlmap->queryForObject("GetDateWithoutResultClass", 1);
+ $orderDate = new TDateTime;
+ $orderDate->setDateTime($date);
+ $date = @mktime(8, 15, 00, 2, 15, 2003);
+
+ $this->assertIdentical($date, $orderDate->getTimeStamp());
+ }
+
+ /**
+ * Test a decimal resultClass
+ */
+ function testDecimal()
+ {
+ $price = $this->sqlmap->queryForObject("GetDecimal", 1);
+ $this->assertIdentical(1.56, $price);
+ }
+
+ /**
+ * Test a decimal implicit resultClass
+ */
+ function testDecimalWithoutResultClass()
+ {
+ $price = $this->sqlmap->queryForObject("GetDecimalWithoutResultClass", 1);
+ $this->assertIdentical(1.56, (float)$price);
+ }
+
+ /**
+ * Test a double resultClass
+ */
+ function testDouble()
+ {
+ $price = $this->sqlmap->queryForObject("GetDouble", 1);
+ $this->assertIdentical(99.5, $price);
+ }
+
+ /**
+ * Test a double implicit resultClass
+ */
+ function testDoubleWithoutResultClass()
+ {
+ $price = $this->sqlmap->queryForObject("GetDoubleWithoutResultClass", 1);
+ $this->assertIdentical(99.5, (float)$price);
+ }
+
+ /**
+ * IBATISNET-25 Error applying ResultMap when using 'Guid' in resultClass
+ */
+/* function testGuid()
+ {
+ Guid newGuid = new Guid("CD5ABF17-4BBC-4C86-92F1-257735414CF4");
+
+ Guid guid = (Guid) $this->sqlmap->queryForObject("GetGuid", 1);
+
+ $this->assertIdentical(newGuid, guid);
+ }
+*/
+
+ /**
+ * Test a Guid implicit resultClass
+ */
+/* function testGuidWithoutResultClass()
+ {
+ Guid newGuid = new Guid("CD5ABF17-4BBC-4C86-92F1-257735414CF4");
+
+ string guidString = Convert.ToString($this->sqlmap->queryForObject("GetGuidWithoutResultClass", 1));
+
+ Guid guid = new Guid(guidString);
+
+ $this->assertIdentical(newGuid, guid);
+ }
+*/
+ /**
+ * Test a int16 resultClass (integer in PHP)
+ */
+ function testInt16()
+ {
+ $integer = $this->sqlmap->queryForObject("GetInt16", 1);
+
+ $this->assertIdentical(32111, $integer);
+ }
+
+ /**
+ * Test a int16 implicit resultClass (integer in PHP)
+ */
+ function testInt16WithoutResultClass()
+ {
+ $integer = $this->sqlmap->queryForObject("GetInt16WithoutResultClass", 1);
+ $this->assertIdentical(32111, (int)$integer);
+ }
+
+ /**
+ * Test a int 32 resultClass (integer in PHP)
+ */
+ function testInt32()
+ {
+ $integer = $this->sqlmap->queryForObject("GetInt32", 1);
+ $this->assertIdentical(999999, $integer);
+ }
+
+ /**
+ * Test a int 32 implicit resultClass (integer in PHP)
+ */
+ function testInt32WithoutResultClass()
+ {
+ $integer = $this->sqlmap->queryForObject("GetInt32WithoutResultClass", 1);
+ $this->assertIdentical(999999, (int)$integer);
+ }
+
+ /**
+ * Test a int64 resultClass (float in PHP)
+ */
+ function testInt64()
+ {
+ $bigInt = $this->sqlmap->queryForObject("GetInt64", 1);
+ $this->assertIdentical(9223372036854775800, $bigInt);
+ }
+
+ /**
+ * Test a int64 implicit resultClass (float in PHP)
+ */
+ function testInt64WithoutResultClass()
+ {
+ $bigInt = $this->sqlmap->queryForObject("GetInt64WithoutResultClass", 1);
+ $this->assertIdentical(9223372036854775800, (double)$bigInt);
+ }
+
+ /**
+ * Test a single/float resultClass
+ */
+ function testSingle()
+ {
+ $price = (float)$this->sqlmap->queryForObject("GetSingle", 1);
+ $this->assertIdentical(92233.5, $price);
+ }
+
+ /**
+ * Test a single/float implicit resultClass
+ */
+ function testSingleWithoutResultClass()
+ {
+ $price = $this->sqlmap->queryForObject("GetSingleWithoutResultClass", 1);
+ $this->assertIdentical(92233.5, (float)$price);
+ }
+
+ /**
+ * Test a string resultClass
+ */
+ function testString()
+ {
+ $cardType = $this->sqlmap->queryForObject("GetString", 1);
+ $this->assertIdentical("VISA", $cardType);
+ }
+
+ /**
+ * Test a string implicit resultClass
+ */
+ function testStringWithoutResultClass()
+ {
+ $cardType = $this->sqlmap->queryForObject("GetStringWithoutResultClass", 1);
+ $this->assertIdentical("VISA", $cardType);
+ }
+/**/
+
+}
diff --git a/tests/unit/Data/SqlMap/ResultMapTest.php b/tests/unit/Data/SqlMap/ResultMapTest.php
new file mode 100644
index 00000000..c757f874
--- /dev/null
+++ b/tests/unit/Data/SqlMap/ResultMapTest.php
@@ -0,0 +1,271 @@
+<?php
+
+require_once(dirname(__FILE__).'/BaseCase.php');
+
+/**
+ * @package System.Data.SqlMap
+ */
+class ResultMapTest extends BaseCase
+{
+ function __construct()
+ {
+ parent::__construct();
+ $this->initSqlMap();
+ new Order;
+ new LineItemCollection;
+ new Account;
+ }
+
+ function resetDatabase()
+ {
+ $this->initScript('account-init.sql');
+ $this->initScript('order-init.sql');
+ $this->initScript('line-item-init.sql');
+// $this->initScript('enumeration-init.sql');
+ }
+
+ function testColumnsByName()
+ {
+ $order = $this->sqlmap->QueryForObject('GetOrderLiteByColumnName', 1);
+ $this->assertOrder1($order);
+ }
+
+ function testColumnsByIndex()
+ {
+ $order = $this->sqlmap->QueryForObject("GetOrderLiteByColumnIndex", 1);
+ $this->assertOrder1($order);
+ }
+
+ function testExtendedResultMap()
+ {
+ $order = $this->sqlmap->queryForObject("GetOrderWithLineItemsNoLazyLoad", 1);
+ $this->assertOrder1($order);
+ $this->assertTrue($order->getLineItemsList() instanceof TList);
+ $this->assertIdentical(2, $order->getLineItemsList()->getCount());
+ }
+
+
+ function testLazyLoad()
+ {
+ $order = $this->sqlmap->QueryForObject("GetOrderWithLineItems", 1);
+ $this->assertOrder1($order);
+ $this->assertNotNull($order->getLineItemsList());
+ $this->assertFalse($order->getLineItemsList() instanceof TList);
+ $this->assertIdentical(2, $order->getLineItemsList()->getCount());
+
+ // After a call to a method from a proxy object,
+ // the proxy object is replaced by the real object.
+ $this->assertTrue($order->getLineItemsList() instanceof TList);
+ $this->assertIdentical(2, $order->getLineItemsList()->getCount());
+ }
+
+ function testLazyWithTypedCollectionMapping()
+ {
+ $order = $this->sqlmap->queryForObject("GetOrderWithLineItemCollection", 1);
+ $this->assertOrder1($order);
+ $this->assertNotNull($order->getLineItems());
+ $this->assertFalse($order->getLineItemsList() instanceof LineItemCollection);
+
+ $this->assertIdentical(2, $order->getLineItems()->getCount());
+
+ // After a call to a method from a proxy object,
+ // the proxy object is replaced by the real object.
+ $this->assertTrue($order->getLineItems() instanceof LineItemCollection);
+ foreach($order->getLineItems() as $item)
+ {
+ $this->assertNotNull($item);
+ $this->assertTrue($item instanceof LineItem);
+ }
+ }
+
+ function testNullValueReplacementOnString()
+ {
+ $account = $this->sqlmap->queryForObject("GetAccountViaColumnName", 5);
+ $this->assertIdentical("no_email@provided.com", $account->getEmailAddress());
+ }
+
+ function testTypeSpecified()
+ {
+ $order = $this->sqlmap->queryForObject("GetOrderWithTypes", 1);
+ $this->assertOrder1($order);
+ }
+
+ function testComplexObjectMapping()
+ {
+ $order = $this->sqlmap->queryForObject("GetOrderWithAccount", 1);
+ $this->assertOrder1($order);
+ $this->assertAccount1($order->getAccount());
+ }
+
+ function testCollectionMappingAndExtends()
+ {
+ $order = $this->sqlmap->queryForObject("GetOrderWithLineItemsCollection", 1);
+ $this->assertOrder1($order);
+
+ // Check strongly typed collection
+ $this->assertNotNull($order->getLineItems());
+ $this->assertIdentical(2, $order->getLineItems()->getCount());
+ }
+
+ function testListMapping()
+ {
+ $order = $this->sqlmap->queryForObject("GetOrderWithLineItems", 1);
+ $this->assertOrder1($order);
+
+ // Check TList collection
+ $this->assertNotNull($order->getLineItemsList());
+ $this->assertIdentical(2, $order->getLineItemsList()->getCount());
+ }
+
+ function testArrayMapping()
+ {
+ $order = $this->sqlmap->queryForObject("GetOrderWithLineItemArray", 1);
+ $this->assertOrder1($order);
+ $this->assertNotNull($order->getLineItemsArray());
+ $this->assertTrue(is_array($order->getLineItemsArray()));
+ $this->assertIdentical(2, count($order->getLineItemsArray()));
+ }
+
+ function testTypedCollectionMapping()
+ {
+ $order = $this->sqlmap->queryForObject("GetOrderWithLineItemCollectionNoLazy", 1);
+ $this->assertOrder1($order);
+ $this->assertNotNull($order->getLineItems());
+ $this->assertTrue($order->getLineItems() instanceof LineItemCollection);
+ $this->assertIdentical(2, $order->getLineItems()->getCount());
+ foreach($order->getLineItems() as $item)
+ {
+ $this->assertNotNull($item);
+ $this->assertTrue($item instanceof LineItem);
+ }
+ }
+
+ function testHashArrayMapping()
+ {
+ $order = $this->sqlmap->queryForObject("GetOrderAsHastable", 1);
+ $this->assertOrder1AsHashArray($order);
+ }
+
+ function testNestedObjects()
+ {
+ $order = $this->sqlmap->queryForObject("GetOrderJoinedFavourite", 1);
+
+ $this->assertOrder1($order);
+ $this->assertNotNull($order->getFavouriteLineItem());
+ $this->assertIdentical(2, (int)$order->getFavouriteLineItem()->getID());
+ $this->assertIdentical("ESM-23", $order->getFavouriteLineItem()->getCode());
+
+ }
+
+
+ function testNestedObjects2()
+ {
+ $order = $this->sqlmap->queryForObject("GetOrderJoinedFavourite2", 1);
+ $this->assertOrder1($order);
+
+ $this->assertNotNull($order->getFavouriteLineItem());
+ $this->assertIdentical(2, (int)$order->getFavouriteLineItem()->getID());
+ $this->assertIdentical("ESM-23", $order->getFavouriteLineItem()->getCode());
+ }
+
+ function testImplicitResultMaps()
+ {
+ $order = $this->sqlmap->queryForObject("GetOrderJoinedFavourite3", 1);
+
+ // *** force date to timestamp since data type can't be
+ // *** explicity known without mapping
+ $order->setDate(new TDateTime($order->getDate()));
+
+ $this->assertOrder1($order);
+
+ $this->assertNotNull($order->getFavouriteLineItem());
+ $this->assertIdentical(2, $order->getFavouriteLineItem()->getID());
+ $this->assertIdentical("ESM-23", $order->getFavouriteLineItem()->getCode());
+ }
+
+ function testCompositeKeyMapping()
+ {
+ $this->resetDatabase();
+
+ $order1 = $this->sqlmap->queryForObject("GetOrderWithFavouriteLineItem", 1);
+ $order2 = $this->sqlmap->queryForObject("GetOrderWithFavouriteLineItem", 2);
+
+ $this->assertNotNull($order1);
+ $this->assertNotNull($order1->getFavouriteLineItem());
+ $this->assertIdentical(2, $order1->getFavouriteLineItem()->getID());
+
+ $this->assertNotNull($order2);
+ $this->assertNotNull($order2->getFavouriteLineItem());
+ $this->assertIdentical(1, $order2->getFavouriteLineItem()->getID());
+ }
+
+
+ function testSimpleTypeMapping()
+ {
+ $this->resetDatabase();
+
+ $list = $this->sqlmap->QueryForList("GetAllCreditCardNumbersFromOrders", null);
+
+ $this->assertIdentical(5, count($list));
+ $this->assertIdentical("555555555555", $list[0]);
+ }
+
+ function testDecimalTypeMapping()
+ {
+ $this->resetDatabase();
+
+ $param["LineItem_ID"] = 1;
+ $param["Order_ID"] = 10;
+ $price = $this->sqlmap->queryForObject("GetLineItemPrice", $param);
+ $this->assertIdentical(gettype($price), 'double');
+ $this->assertIdentical(45.43, $price);
+ }
+
+//todo
+/*
+ function testNullValueReplacementOnEnum()
+ {
+ $enum['Id'] = 99;
+ $enum['Day'] = 'Days.Thu';
+ $enum['Color'] = 'Colors.Blue';
+ $enum['Month'] = 'Months.All';
+
+ $this->sqlmap->insert("InsertEnumViaParameterMap", $enum);
+
+ $enumClass = $this->sqlmap->queryForObject("GetEnumerationNullValue", 99);
+
+ $this->assertIdentical($enumClass['Day'], 'Days.Thu');
+ $this->asserEquals($enumClass['Color'], 'Colors.Blue');
+ $this->assertIdentical($enumClass['Month'], 'Months.All');
+ }
+
+
+ function testByteArrayMapping()
+ {
+ }
+
+ function testNullValueReplacementOnDecimal()
+ {
+ }
+
+ function testNullValueReplacementOnDateTime()
+ {
+ }
+*/
+
+//future work
+
+/*
+ //requires dynamic SQL
+ function testDynamiqueCompositeKeyMapping()
+ {
+ $order1 = $this->sqlmap->queryForObject("GetOrderWithDynFavouriteLineItem", 1);
+
+ $this->assertNotNull($order1);
+ $this->assertNotNull($order1->getFavouriteLineItem());
+ var_dump($order1);
+ $this->assertIdentical(2, $order1->getFavouriteLineItem()->getID());
+ }
+*/
+
+}
diff --git a/tests/unit/Data/SqlMap/SelectKeyTest.php b/tests/unit/Data/SqlMap/SelectKeyTest.php
new file mode 100644
index 00000000..a0554aef
--- /dev/null
+++ b/tests/unit/Data/SqlMap/SelectKeyTest.php
@@ -0,0 +1,118 @@
+<?php
+
+require_once(dirname(__FILE__).'/BaseCase.php');
+
+/**
+ * @package System.Data.SqlMap
+ */
+class SelectKeyTest extends BaseCase
+{
+ function __construct()
+ {
+ parent::__construct();
+ $this->initSqlMap();
+
+ //force autoload
+ new Account;
+ new Order;
+ new LineItem;
+ new LineItemCollection;
+ new A; new B; new C; new D; new E; new F;
+ }
+
+ /**
+ * Test Insert with post GeneratedKey
+ */
+ function testInsertPostKey()
+ {
+ $this->initScript('line-item-init.sql');
+
+ $item = new LineItem();
+
+ $item->setId(10);
+ $item->setCode("blah");
+ $item->setOrder(new Order());
+ $item->getOrder()->setId(9);
+ $item->setPrice(44.00);
+ $item->setQuantity(1);
+
+ $key = $this->sqlmap->Insert("InsertLineItemPostKey", $item);
+
+ $this->assertIdentical(99, $key);
+ $this->assertIdentical(99, $item->getId());
+
+ $param["Order_ID"] = 9;
+ $param["LineItem_ID"] =10;
+ $testItem = $this->sqlmap->QueryForObject("GetSpecificLineItem", $param);
+
+ $this->assertNotNull($testItem);
+ $this->assertIdentical(10, $testItem->getId());
+
+ $this->initScript('line-item-init.sql');
+ }
+
+ /**
+ * Test Insert pre GeneratedKey
+ */
+ function testInsertPreKey()
+ {
+ $this->initScript('line-item-init.sql');
+
+ $item = new LineItem();
+
+ $item->setId(10);
+ $item->setCode("blah");
+ $item->setOrder(new Order());
+ $item->getOrder()->setId(9);
+ $item->setPrice(44.00);
+ $item->setQuantity(1);
+
+ $key = $this->sqlmap->Insert("InsertLineItemPreKey", $item);
+
+ $this->assertIdentical(99, $key);
+ $this->assertIdentical(99, $item->getId());
+
+ $param["Order_ID"] = 9;
+ $param["LineItem_ID"] = 99;
+
+ $testItem = $this->sqlmap->QueryForObject("GetSpecificLineItem", $param);
+
+ $this->assertNotNull($testItem);
+ $this->assertIdentical(99, $testItem->getId());
+
+ $this->initScript('line-item-init.sql');
+ }
+
+ /**
+ * Test Test Insert No Key
+ */
+ function testInsertNoKey()
+ {
+ $this->initScript('line-item-init.sql');
+
+ $item = new LineItem();
+
+ $item->setId(100);
+ $item->setCode("blah");
+ $item->setOrder(new Order());
+ $item->getOrder()->setId(9);
+ $item->setPrice(44.00);
+ $item->setQuantity(1);
+
+
+ $key = $this->sqlmap->Insert("InsertLineItemNoKey", $item);
+
+ $this->assertNull($key);
+ $this->assertIdentical(100, $item->getId());
+
+ $param["Order_ID"] = 9;
+ $param["LineItem_ID"] = 100;
+
+ $testItem = $this->sqlmap->QueryForObject("GetSpecificLineItem", $param);
+
+ $this->assertNotNull($testItem);
+ $this->assertIdentical(100, $testItem->getId());
+
+ $this->initScript('line-item-init.sql');
+ }
+}
diff --git a/tests/unit/Data/SqlMap/SqlMapCacheTest.php b/tests/unit/Data/SqlMap/SqlMapCacheTest.php
new file mode 100644
index 00000000..57851217
--- /dev/null
+++ b/tests/unit/Data/SqlMap/SqlMapCacheTest.php
@@ -0,0 +1,75 @@
+<?php
+
+require_once(dirname(__FILE__).'/BaseCase.php');
+
+/**
+ * @package System.Data.SqlMap
+ */
+class SqlMapCacheTest extends PHPUnit_Framework_TestCase
+{
+ function testFIFOCache()
+ {
+ $fifo = new TSqlMapFifoCache(2);
+ $object1 = new TSqlMapManager;
+ $object2 = new TComponent;
+ $object3 = new TSqlMapGateway(null);
+
+ $key1 = 'key1';
+ $key2 = 'key2';
+ $key3 = 'key3';
+
+ $fifo->set($key1, $object1);
+ $fifo->set($key2, $object2);
+
+ $this->assertTrue($object1 === $fifo->get($key1));
+ $this->assertTrue($object2 === $fifo->get($key2));
+
+ //object 1 should be removed
+ $fifo->set($key3, $object3);
+
+ $this->assertNull($fifo->get($key1));
+ $this->assertTrue($object2 === $fifo->get($key2));
+ $this->assertTrue($object3 === $fifo->get($key3));
+
+ //object 2 should be removed
+ $fifo->set($key1, $object1);
+
+ $this->assertNull($fifo->get($key2));
+ $this->assertTrue($object3 === $fifo->get($key3));
+ $this->assertTrue($object1 === $fifo->get($key1));
+ }
+
+ function testLruCache()
+ {
+ $lru = new TSqlMapLruCache(2);
+
+ $object1 = new TSqlMapManager;
+ $object2 = new TComponent;
+ $object3 = new TSqlMapGateway(null);
+
+ $key1 = 'key1';
+ $key2 = 'key2';
+ $key3 = 'key3';
+
+ $lru->set($key1, $object1);
+ $lru->set($key2, $object2);
+
+ $this->assertTrue($object2 === $lru->get($key2));
+ $this->assertTrue($object1 === $lru->get($key1));
+
+ //object 2 should be removed, i.e. least recently used
+ $lru->set($key3, $object3);
+
+ $this->assertNull($lru->get($key2));
+ $this->assertTrue($object1 === $lru->get($key1));
+ $this->assertTrue($object3 === $lru->get($key3));
+
+ //object 1 will be removed
+ $lru->set($key2, $object2);
+
+ $this->assertNull($lru->get($key1));
+ $this->assertTrue($object2 === $lru->get($key2));
+ $this->assertTrue($object3 === $lru->get($key3));
+ }
+}
+
diff --git a/tests/unit/Data/SqlMap/StatementExtendsTest.php b/tests/unit/Data/SqlMap/StatementExtendsTest.php
new file mode 100644
index 00000000..15d00e39
--- /dev/null
+++ b/tests/unit/Data/SqlMap/StatementExtendsTest.php
@@ -0,0 +1,31 @@
+<?php
+
+Prado::using('System.Data.SqlMap.TSqlMapConfig');
+
+/**
+ * @package System.Data.SqlMap
+ */
+class StatementExtendsTest extends PHPUnit_Framework_TestCase
+{
+ protected $sqlmap;
+
+ function setup()
+ {
+ $config = new TSqlMapConfig();
+ $config->ConfigFile = dirname(__FILE__).'/maps/tests.xml';
+ $this->sqlmap = $config->getClient();
+ }
+
+ function test_extends1()
+ {
+ $manager = $this->sqlmap->SqlMapManager;
+ $sql = $manager->getMappedStatement('test')->getSqlString();
+
+ $this->assertPattern('/img_request/', $sql);
+ $this->assertNoPattern('/img_progress/', $sql);
+
+ $sql2 = $manager->getMappedStatement('GetAllProgress')->getSqlString();
+ $this->assertPattern('/img_request/', $sql2);
+ $this->assertPattern('/img_progress/', $sql2);
+ }
+}
diff --git a/tests/unit/Data/SqlMap/StatementTest.php b/tests/unit/Data/SqlMap/StatementTest.php
new file mode 100644
index 00000000..bdcc3ae7
--- /dev/null
+++ b/tests/unit/Data/SqlMap/StatementTest.php
@@ -0,0 +1,1133 @@
+<?php
+require_once(dirname(__FILE__).'/BaseCase.php');
+
+/**
+ * @package System.Data.SqlMap
+ */
+class StatementTest extends BaseCase
+{
+ function __construct()
+ {
+ parent::__construct();
+ $this->initSqlMap();
+
+ //force autoload
+ new Account;
+ new Order;
+ new LineItem;
+ new LineItemCollection;
+ new A; new B; new C; new D; new E; new F;
+ }
+
+ public function setup()
+ {
+
+ }
+
+ function resetDatabase()
+ {
+ $this->initScript('account-init.sql');
+ $this->initScript('order-init.sql');
+ $this->initScript('line-item-init.sql');
+// $this->initScript('enumeration-init.sql');
+ $this->initScript('other-init.sql');
+ }
+
+
+ #region Object Query tests
+
+ /**
+ * Test Open connection with a connection string
+ */
+ function testOpenConnection()
+ {
+ $conn = $this->sqlmap->getDbConnection();
+ $conn->setActive(true);
+ $account= $this->sqlmap->QueryForObject("SelectWithProperty");
+ $conn->setActive(false);
+ $this->assertAccount1($account);
+ }
+
+ /**
+ * Test use a statement with property subtitution
+ * (JIRA 22)
+ */
+ function testSelectWithProperty()
+ {
+ $account= $this->sqlmap->QueryForObject("SelectWithProperty");
+ $this->assertAccount1($account);
+ }
+
+ /**
+ * Test ExecuteQueryForObject Via ColumnName
+ */
+ function testExecuteQueryForObjectViaColumnName()
+ {
+ $account= $this->sqlmap->QueryForObject("GetAccountViaColumnName", 1);
+ $this->assertAccount1($account);
+ }
+
+ /**
+ * Test ExecuteQueryForObject Via ColumnIndex
+ */
+ function testExecuteQueryForObjectViaColumnIndex()
+ {
+ $account= $this->sqlmap->QueryForObject("GetAccountViaColumnIndex", 1);
+ $this->assertAccount1($account);
+ }
+
+ /**
+ * Test ExecuteQueryForObject Via ResultClass
+ */
+ function testExecuteQueryForObjectViaResultClass()
+ {
+ $account= $this->sqlmap->QueryForObject("GetAccountViaResultClass", 1);
+ $this->assertAccount1($account);
+ }
+
+ /**
+ * Test ExecuteQueryForObject With simple ResultClass : string
+ */
+ function testExecuteQueryForObjectWithSimpleResultClass()
+ {
+ $email = $this->sqlmap->QueryForObject("GetEmailAddressViaResultClass", 1);
+ $this->assertIdentical("Joe.Dalton@somewhere.com", $email);
+ }
+
+ /**
+ * Test ExecuteQueryForObject With simple ResultMap : string
+ */
+ function testExecuteQueryForObjectWithSimpleResultMap()
+ {
+ $email = $this->sqlmap->QueryForObject("GetEmailAddressViaResultMap", 1);
+ $this->assertIdentical("Joe.Dalton@somewhere.com", $email);
+ }
+
+ /**
+ * Test Primitive ReturnValue : TDateTime
+ */
+ function testPrimitiveReturnValue()
+ {
+ $CardExpiry = $this->sqlmap->QueryForObject("GetOrderCardExpiryViaResultClass", 1);
+ $date = @mktime(8, 15, 00, 2, 15, 2003);
+ $this->assertIdentical($date, $CardExpiry->getTimeStamp());
+ }
+
+ /**
+ * Test ExecuteQueryForObject with result object : Account
+ */
+ function testExecuteQueryForObjectWithResultObject()
+ {
+ $account= new Account();
+ $testAccount = $this->sqlmap->QueryForObject("GetAccountViaColumnName", 1, $account);
+ $this->assertAccount1($account);
+ $this->assertTrue($account == $testAccount);
+ }
+
+ /**
+ * Test ExecuteQueryForObject as array
+ */
+ function testExecuteQueryForObjectAsHashArray()
+ {
+ $account = $this->sqlmap->QueryForObject("GetAccountAsHashtable", 1);
+ $this->assertAccount1AsHashArray($account);
+ }
+
+ /**
+ * Test ExecuteQueryForObject as Hashtable ResultClass
+ */
+ function testExecuteQueryForObjectAsHashtableResultClass()
+ {
+ $account = $this->sqlmap->QueryForObject("GetAccountAsHashtableResultClass", 1);
+ $this->assertAccount1AsHashArray($account);
+ }
+
+ /**
+ * Test ExecuteQueryForObject via Hashtable
+ */
+ function testExecuteQueryForObjectViaHashtable()
+ {
+ $param["LineItem_ID"] = 2;
+ $param["Order_ID"] = 9;
+
+ $testItem = $this->sqlmap->QueryForObject("GetSpecificLineItem", $param);
+
+ $this->assertNotNull($testItem);
+ $this->assertIdentical("TSM-12", $testItem->getCode());
+ }
+ /**/
+
+ //TODO: Test Query Dynamic Sql Element
+ function testQueryDynamicSqlElement()
+ {
+ //$list = $this->sqlmap->QueryForList("GetDynamicOrderedEmailAddressesViaResultMap", "Account_ID");
+
+ //$this->assertIdentical("Joe.Dalton@somewhere.com", $list[0]);
+
+ //list = $this->sqlmap->QueryForList("GetDynamicOrderedEmailAddressesViaResultMap", "Account_FirstName");
+
+ //$this->assertIdentical("Averel.Dalton@somewhere.com", $list[0]);
+
+ }
+
+ // TODO: Test Execute QueryForList With ResultMap With Dynamic Element
+ function testExecuteQueryForListWithResultMapWithDynamicElement()
+ {
+ //$list = $this->sqlmap->QueryForList("GetAllAccountsViaResultMapWithDynamicElement", "LIKE");
+
+ //$this->assertAccount1$list[0]);
+ //$this->assertIdentical(3, $list->getCount());
+ //$this->assertIdentical(1, $list[0]->getID());
+ //$this->assertIdentical(2, $list[1]->getID());
+ //$this->assertIdentical(4, $list[2]->getID());
+
+ //list = $this->sqlmap->QueryForList("GetAllAccountsViaResultMapWithDynamicElement", "=");
+
+ //$this->assertIdentical(0, $list->getCount());
+ }
+
+
+
+ /**
+ * Test Get Account Via Inline Parameters
+ */
+ function testExecuteQueryForObjectViaInlineParameters()
+ {
+ $account= new Account();
+ $account->setID(1);
+
+ $testAccount = $this->sqlmap->QueryForObject("GetAccountViaInlineParameters", $account);
+
+ $this->assertAccount1($testAccount);
+ }
+ /**/
+
+ // TODO: Test ExecuteQuery For Object With Enum property
+
+ function testExecuteQueryForObjectWithEnum()
+ {
+ //$enumClass = $this->sqlmap->QueryForObject("GetEnumeration", 1);
+
+ //$this->assertIdentical(enumClass.Day, Days.Sat);
+ //$this->assertIdentical(enumClass.Color, Colors.Red);
+ //$this->assertIdentical(enumClass.Month, Months.August);
+
+ //enumClass = $this->sqlmap->QueryForObject("GetEnumeration", 3) as Enumeration;
+
+ //$this->assertIdentical(enumClass.Day, Days.Mon);
+ //$this->assertIdentical(enumClass.Color, Colors.Blue);
+ //$this->assertIdentical(enumClass.Month, Months.September);*/
+ }
+
+ #endregion
+
+ #region List Query tests
+
+ /**
+ * Test QueryForList with Hashtable ResultMap
+ */
+ function testQueryForListWithHashtableResultMap()
+ {
+ $this->initScript('account-init.sql');
+ $list = $this->sqlmap->QueryForList("GetAllAccountsAsHashMapViaResultMap");
+
+ $this->assertAccount1AsHashArray($list[0]);
+ $this->assertIdentical(5, count($list));
+
+ $this->assertIdentical(1, (int)$list[0]["Id"]);
+ $this->assertIdentical(2, (int)$list[1]["Id"]);
+ $this->assertIdentical(3, (int)$list[2]["Id"]);
+ $this->assertIdentical(4, (int)$list[3]["Id"]);
+ $this->assertIdentical(5, (int)$list[4]["Id"]);
+ }
+
+ /**
+ * Test QueryForList with Hashtable ResultClass
+ */
+ function testQueryForListWithHashtableResultClass()
+ {
+ $list = $this->sqlmap->QueryForList("GetAllAccountsAsHashtableViaResultClass");
+
+ $this->assertAccount1AsHashArray($list[0]);
+ $this->assertIdentical(5, count($list));
+
+ $this->assertIdentical(1, (int)$list[0]["Id"]);
+ $this->assertIdentical(2, (int)$list[1]["Id"]);
+ $this->assertIdentical(3, (int)$list[2]["Id"]);
+ $this->assertIdentical(4, (int)$list[3]["Id"]);
+ $this->assertIdentical(5, (int)$list[4]["Id"]);
+ }
+
+ /**
+ * Test QueryForList with IList ResultClass
+ */
+ function testQueryForListWithIListResultClass()
+ {
+ $list = $this->sqlmap->QueryForList("GetAllAccountsAsArrayListViaResultClass");
+
+ $listAccount = $list[0];
+
+ $this->assertIdentical(1,(int)$listAccount[0]);
+ $this->assertIdentical("Joe",$listAccount[1]);
+ $this->assertIdentical("Dalton",$listAccount[2]);
+ $this->assertIdentical("Joe.Dalton@somewhere.com",$listAccount[3]);
+
+ $this->assertIdentical(5, count($list));
+
+ $listAccount = $list[0];
+ $this->assertIdentical(1, (int)$listAccount[0]);
+ $listAccount = $list[1];
+ $this->assertIdentical(2, (int)$listAccount[0]);
+ $listAccount = $list[2];
+ $this->assertIdentical(3, (int)$listAccount[0]);
+ $listAccount = $list[3];
+ $this->assertIdentical(4, (int)$listAccount[0]);
+ $listAccount = $list[4];
+ $this->assertIdentical(5, (int)$listAccount[0]);
+ }
+
+ /**
+ * Test QueryForList With ResultMap, result collection as ArrayList
+ */
+ function testQueryForListWithResultMap()
+ {
+ $list = $this->sqlmap->QueryForList("GetAllAccountsViaResultMap");
+
+ $this->assertAccount1($list[0]);
+ $this->assertIdentical(5, count($list));
+ $this->assertIdentical(1, $list[0]->getID());
+ $this->assertIdentical(2, $list[1]->getID());
+ $this->assertIdentical(3, $list[2]->getID());
+ $this->assertIdentical(4, $list[3]->getID());
+ $this->assertIdentical(5, $list[4]->getID());
+ }
+
+ /**
+ * Test ExecuteQueryForPaginatedList
+ */
+ function testExecuteQueryForPaginatedList()
+ {
+ // Get List of all 5
+ $list = $this->sqlmap->QueryForPagedList("GetAllAccountsViaResultMap", null, 2);
+
+ // Test initial state (page 0)
+ $this->assertFalse($list->getIsPreviousPageAvailable());
+ $this->assertTrue($list->getIsNextPageAvailable());
+ $this->assertAccount1($list[0]);
+ $this->assertIdentical(2, $list->getCount());
+ $this->assertIdentical(1, $list[0]->getID());
+ $this->assertIdentical(2, $list[1]->getID());
+
+ // Test illegal previous page (no effect, state should be same)
+ $list->PreviousPage();
+ $this->assertFalse($list->getIsPreviousPageAvailable());
+ $this->assertTrue($list->getIsNextPageAvailable());
+ $this->assertAccount1($list[0]);
+ $this->assertIdentical(2, $list->getCount());
+ $this->assertIdentical(1, $list[0]->getID());
+ $this->assertIdentical(2, $list[1]->getID());
+
+ // Test next (page 1)
+ $list->NextPage();
+ $this->assertTrue($list->getIsPreviousPageAvailable());
+ $this->assertTrue($list->getIsNextPageAvailable());
+ $this->assertIdentical(2, $list->getCount());
+ $this->assertIdentical(3, $list[0]->getID());
+ $this->assertIdentical(4, $list[1]->getID());
+
+ // Test next (page 2 -last)
+ $list->NextPage();
+ $this->assertTrue($list->getIsPreviousPageAvailable());
+ $this->assertFalse($list->getIsNextPageAvailable());
+ $this->assertIdentical(1, $list->getCount());
+ $this->assertIdentical(5, $list[0]->getID());
+
+ // Test previous (page 1)
+ $list->PreviousPage();
+ $this->assertTrue($list->getIsPreviousPageAvailable());
+ $this->assertTrue($list->getIsNextPageAvailable());
+ $this->assertIdentical(2, $list->getCount());
+ $this->assertIdentical(3, $list[0]->getID());
+ $this->assertIdentical(4, $list[1]->getID());
+
+ // Test previous (page 0 -first)
+ $list->PreviousPage();
+ $this->assertFalse($list->getIsPreviousPageAvailable());
+ $this->assertTrue($list->getIsNextPageAvailable());
+ $this->assertAccount1($list[0]);
+ $this->assertIdentical(2, $list->getCount());
+ $this->assertIdentical(1, $list[0]->getID());
+ $this->assertIdentical(2, $list[1]->getID());
+
+ // Test goto (page 0)
+ $list->GotoPage(0);
+ $this->assertFalse($list->getIsPreviousPageAvailable());
+ $this->assertTrue($list->getIsNextPageAvailable());
+ $this->assertIdentical(2, $list->getCount());
+ $this->assertIdentical(1, $list[0]->getID());
+ $this->assertIdentical(2, $list[1]->getID());
+
+ // Test goto (page 1)
+ $list->GotoPage(1);
+ $this->assertTrue($list->getIsPreviousPageAvailable());
+ $this->assertTrue($list->getIsNextPageAvailable());
+ $this->assertIdentical(2, $list->getCount());
+ $this->assertIdentical(3, $list[0]->getID());
+ $this->assertIdentical(4, $list[1]->getID());
+
+ // Test goto (page 2)
+ $list->GotoPage(2);
+ $this->assertTrue($list->getIsPreviousPageAvailable());
+ $this->assertFalse($list->getIsNextPageAvailable());
+ $this->assertIdentical(1, $list->getCount());
+ $this->assertIdentical(5, $list[0]->getID());
+
+ // Test illegal goto (page 0)
+ $list->GotoPage(3);
+ $this->assertTrue($list->getIsPreviousPageAvailable());
+ $this->assertFalse($list->getIsNextPageAvailable());
+ $this->assertIdentical(0, $list->getCount());
+
+ $list = $this->sqlmap->QueryForPagedList("GetNoAccountsViaResultMap", null, 2);
+
+ // Test empty list
+ $this->assertFalse($list->getIsPreviousPageAvailable());
+ $this->assertFalse($list->getIsNextPageAvailable());
+ $this->assertIdentical(0, $list->getCount());
+
+ // Test next
+ $list->NextPage();
+ $this->assertFalse($list->getIsPreviousPageAvailable());
+ $this->assertFalse($list->getIsNextPageAvailable());
+ $this->assertIdentical(0, $list->getCount());
+
+ // Test previous
+ $list->PreviousPage();
+ $this->assertFalse($list->getIsPreviousPageAvailable());
+ $this->assertFalse($list->getIsNextPageAvailable());
+ $this->assertIdentical(0, $list->getCount());
+
+ // Test previous
+ $list->GotoPage(0);
+ $this->assertFalse($list->getIsPreviousPageAvailable());
+ $this->assertFalse($list->getIsNextPageAvailable());
+ $this->assertIdentical(0, $list->getCount());
+ $list = $this->sqlmap->QueryForPagedList("GetFewAccountsViaResultMap", null, 2);
+
+ $this->assertFalse($list->getIsPreviousPageAvailable());
+ $this->assertFalse($list->getIsNextPageAvailable());
+ $this->assertIdentical(1, $list->getCount());
+
+ // Test next
+ $list->NextPage();
+ $this->assertFalse($list->getIsPreviousPageAvailable());
+ $this->assertFalse($list->getIsNextPageAvailable());
+ $this->assertIdentical(1, $list->getCount());
+ // Test previous
+ $list->PreviousPage();
+ $this->assertFalse($list->getIsPreviousPageAvailable());
+ $this->assertFalse($list->getIsNextPageAvailable());
+ $this->assertIdentical(1, $list->getCount());
+
+ // Test previous
+ $list->GotoPage(0);
+ $this->assertFalse($list->getIsPreviousPageAvailable());
+ $this->assertFalse($list->getIsNextPageAvailable());
+ $this->assertIdentical(1, $list->getCount());
+
+
+ $list = $this->sqlmap->QueryForPagedList("GetAllAccountsViaResultMap", null, 5);
+
+ $this->assertIdentical(5, $list->getCount());
+
+ $list->NextPage();
+ $this->assertIdentical(5, $list->getCount());
+
+ $b = $list->getIsPreviousPageAvailable();
+ $list->PreviousPage();
+ $this->assertIdentical(5, $list->getCount());
+ }
+
+ /**
+ * Test QueryForList with ResultObject :
+ * AccountCollection strongly typed collection
+ */
+ function testQueryForListWithResultObject()
+ {
+ $accounts = new AccountCollection();
+
+ $this->sqlmap->QueryForList("GetAllAccountsViaResultMap", null, $accounts);
+ $this->assertAccount1($accounts[0]);
+ $this->assertIdentical(5, $accounts->getCount());
+ $this->assertIdentical(1, $accounts[0]->getID());
+ $this->assertIdentical(2, $accounts[1]->getID());
+ $this->assertIdentical(3, $accounts[2]->getID());
+ $this->assertIdentical(4, $accounts[3]->getID());
+ $this->assertIdentical(5, $accounts[4]->GetId());
+ }
+
+ /**
+ * Test QueryForList with ListClass : LineItemCollection
+ */
+ function testQueryForListWithListClass()
+ {
+ $linesItem = $this->sqlmap->QueryForList("GetLineItemsForOrderWithListClass", 10);
+
+ $this->assertNotNull($linesItem);
+ $this->assertIdentical(2, $linesItem->getCount());
+ $this->assertIdentical("ESM-34", $linesItem[0]->getCode());
+ $this->assertIdentical("QSM-98", $linesItem[1]->getCode());
+ }
+
+ /**
+ * Test QueryForList with no result.
+ */
+ function testQueryForListWithNoResult()
+ {
+ $list = $this->sqlmap->QueryForList("GetNoAccountsViaResultMap");
+
+ $this->assertIdentical(0, count($list));
+ }
+
+ /**
+ * Test QueryForList with ResultClass : Account.
+ */
+ function testQueryForListResultClass()
+ {
+ $list = $this->sqlmap->QueryForList("GetAllAccountsViaResultClass");
+
+ $this->assertAccount1($list[0]);
+ $this->assertIdentical(5, count($list));
+ $this->assertIdentical(1, $list[0]->getID());
+ $this->assertIdentical(2, $list[1]->getID());
+ $this->assertIdentical(3, $list[2]->getID());
+ $this->assertIdentical(4, $list[3]->getID());
+ $this->assertIdentical(5, $list[4]->getID());
+ }
+
+ /**
+ * Test QueryForList with simple resultClass : string
+ */
+ function testQueryForListWithSimpleResultClass()
+ {
+ $list = $this->sqlmap->QueryForList("GetAllEmailAddressesViaResultClass");
+
+ $this->assertIdentical("Joe.Dalton@somewhere.com", $list[0]);
+ $this->assertIdentical("Averel.Dalton@somewhere.com", $list[1]);
+ $this->assertIdentical('', $list[2]);
+ $this->assertIdentical("Jack.Dalton@somewhere.com", $list[3]);
+ $this->assertIdentical('', $list[4]);
+ }
+
+ /**
+ * Test QueryForList with simple ResultMap : string
+ */
+ function testQueryForListWithSimpleResultMap()
+ {
+ $list = $this->sqlmap->QueryForList("GetAllEmailAddressesViaResultMap");
+
+ $this->assertIdentical("Joe.Dalton@somewhere.com", $list[0]);
+ $this->assertIdentical("Averel.Dalton@somewhere.com", $list[1]);
+ $this->assertIdentical('', $list[2]);
+ $this->assertIdentical("Jack.Dalton@somewhere.com", $list[3]);
+ $this->assertIdentical('', $list[4]);
+ }
+
+ /**
+ * Test QueryForListWithSkipAndMax
+ */
+ function testQueryForListWithSkipAndMax()
+ {
+ $list = $this->sqlmap->QueryForList("GetAllAccountsViaResultMap", null, null, 2, 2);
+
+ $this->assertIdentical(2, count($list));
+ $this->assertIdentical(3, $list[0]->getID());
+ $this->assertIdentical(4, $list[1]->getID());
+ }
+
+
+ /**
+ * Test row delegate
+ */
+ function testQueryWithRowDelegate()
+ {
+ //$handler = new SqlMapper.RowDelegate(this.RowHandler);
+
+ //$list = $this->sqlmap->QueryWithRowDelegate("GetAllAccountsViaResultMap", null, handler);
+
+ //$this->assertIdentical(5, _index);
+ //$this->assertIdentical(5, $list->getCount());
+ //$this->assertAccount1$list[0]);
+ //$this->assertIdentical(1, $list[0]->getID());
+ //$this->assertIdentical(2, $list[1]->getID());
+ //$this->assertIdentical(3, $list[2]->getID());
+ //$this->assertIdentical(4, $list[3]->getID());
+ //$this->assertIdentical(5, $list[4]->getID());
+ }
+
+ #endregion
+
+ #region Map Tests
+
+ /**
+ * Test ExecuteQueryForMap : Hashtable.
+ */
+ function testExecuteQueryForMap()
+ {
+ $map = $this->sqlmap->QueryForMap("GetAllAccountsViaResultClass", null, "FirstName");
+
+ $this->assertIdentical(5, count($map));
+ $this->assertAccount1($map["Joe"]);
+
+ $this->assertIdentical(1, $map["Joe"]->getID());
+ $this->assertIdentical(2, $map["Averel"]->getID());
+ $this->assertIdentical(3, $map["William"]->getID());
+ $this->assertIdentical(4, $map["Jack"]->getID());
+ $this->assertIdentical(5, $map["Gilles"]->getID());
+ }
+
+ /**
+ * Test ExecuteQueryForMap : Hashtable.
+ *
+ * If the keyProperty is an integer, you must acces the map
+ * by map[integer] and not by map["integer"]
+ */
+ function testExecuteQueryForMap2()
+ {
+ $map = $this->sqlmap->QueryForMap("GetAllOrderWithLineItems", null, "PostalCode");
+
+ $this->assertIdentical(11, count($map));
+ $order = $map["T4H 9G4"];
+
+ $this->assertIdentical(2, $order->getLineItemsList()->getCount());
+ }
+
+ /**
+ * Test ExecuteQueryForMap with value property :
+ * "FirstName" as key, "EmailAddress" as value
+ */
+ function testExecuteQueryForMapWithValueProperty()
+ {
+ $map = $this->sqlmap->QueryForMap("GetAllAccountsViaResultClass", null,
+ "FirstName", "EmailAddress");
+
+ $this->assertIdentical(5, count($map));
+
+ $this->assertIdentical("Joe.Dalton@somewhere.com", $map["Joe"]);
+ $this->assertIdentical("Averel.Dalton@somewhere.com", $map["Averel"]);
+ $this->assertNull($map["William"]);
+ $this->assertIdentical("Jack.Dalton@somewhere.com", $map["Jack"]);
+ $this->assertNull($map["Gilles"]);
+ }
+
+ /**
+ * Test ExecuteQueryForWithJoined
+ */
+ function testExecuteQueryForWithJoined()
+ {
+ $order = $this->sqlmap->QueryForObject("GetOrderJoinWithAccount",10);
+
+ $this->assertNotNull($order->getAccount());
+
+ $order = $this->sqlmap->QueryForObject("GetOrderJoinWithAccount",11);
+
+ $this->assertNull($order->getAccount());
+ }
+
+ /**
+ * Test ExecuteQueryFor With Complex Joined
+ *
+ * A->B->C
+ * ->E
+ * ->F
+ */
+ function testExecuteQueryForWithComplexJoined()
+ {
+ $a = $this->sqlmap->QueryForObject("SelectComplexJoined");
+ $this->assertNotNull($a);
+ $this->assertNotNull($a->getB());
+ $this->assertNotNull($a->getB()->getC());
+ $this->assertNull($a->getB()->getD());
+ $this->assertNotNull($a->getE());
+ $this->assertNull($a->getF());
+ }
+ #endregion
+
+ #region Extends statement
+
+ /**
+ * Test base Extends statement
+ */
+ function testExtendsGetAllAccounts()
+ {
+ $list = $this->sqlmap->QueryForList("GetAllAccounts");
+
+ $this->assertAccount1($list[0]);
+ $this->assertIdentical(5, count($list));
+ $this->assertIdentical(1, $list[0]->getID());
+ $this->assertIdentical(2, $list[1]->getID());
+ $this->assertIdentical(3, $list[2]->getID());
+ $this->assertIdentical(4, $list[3]->getID());
+ $this->assertIdentical(5, $list[4]->getID());
+ }
+
+ /**
+ * Test Extends statement GetAllAccountsOrderByName extends GetAllAccounts
+ */
+ function testExtendsGetAllAccountsOrderByName()
+ {
+ $list = $this->sqlmap->QueryForList("GetAllAccountsOrderByName");
+
+ $this->assertAccount1($list[3]);
+ $this->assertIdentical(5, count($list));
+
+ $this->assertIdentical(2, $list[0]->getID());
+ $this->assertIdentical(5, $list[1]->getID());
+ $this->assertIdentical(4, $list[2]->getID());
+ $this->assertIdentical(1, $list[3]->getID());
+ $this->assertIdentical(3, $list[4]->getID());
+ }
+
+ /**
+ * Test Extends statement GetOneAccount extends GetAllAccounts
+ */
+ function testExtendsGetOneAccount()
+ {
+ $account= $this->sqlmap->QueryForObject("GetOneAccount", 1);
+ $this->assertAccount1($account);
+ }
+
+ /**
+ * Test Extends statement GetSomeAccount extends GetAllAccounts
+ */
+ function testExtendsGetSomeAccount()
+ {
+ $param["lowID"] = 2;
+ $param["hightID"] = 4;
+
+ $list = $this->sqlmap->QueryForList("GetSomeAccount", $param);
+
+ $this->assertIdentical(3, count($list));
+
+ $this->assertIdentical(2, $list[0]->getID());
+ $this->assertIdentical(3, $list[1]->getID());
+ $this->assertIdentical(4, $list[2]->getID());
+ }
+
+ #endregion
+
+ #region Update tests
+
+
+ /**
+ * Test Insert account via public fields
+ */
+ function testInsertAccountViaPublicFields()
+ {
+ $this->initScript('account-init.sql');
+
+ $account = new AccountBis();
+
+ $account->Id = 10;
+ $account->FirstName = "Luky";
+ $account->LastName = "Luke";
+ $account->EmailAddress = "luly.luke@somewhere.com";
+
+ $this->sqlmap->Insert("InsertAccountViaPublicFields", $account);
+
+ $testAccount = $this->sqlmap->QueryForObject("GetAccountViaColumnName", 10);
+
+ $this->assertNotNull($testAccount);
+
+ $this->assertIdentical(10, $testAccount->getID());
+
+ $this->initScript('account-init.sql');
+ }
+
+ /**
+ *
+ */
+ function testInsertOrderViaProperties()
+ {
+ $this->initScript('account-init.sql');
+ $this->initScript('order-init.sql');
+ $account= $this->NewAccount6();
+
+ $this->sqlmap->Insert("InsertAccountViaParameterMap", $account);
+
+ $order = new Order();
+ $order->setId(99);
+ $order->setCardExpiry("09/11");
+ $order->setAccount($account);
+ $order->setCardNumber("154564656");
+ $order->setCardType("Visa");
+ $order->setCity("Lyon");
+ $order->setDate('2005-05-20');
+ $order->setPostalCode("69004");
+ $order->setProvince("Rhone");
+ $order->setStreet("rue Durand");
+
+ $this->sqlmap->Insert("InsertOrderViaPublicFields", $order);
+
+ $this->initScript('account-init.sql');
+ $this->initScript('order-init.sql');
+ }
+
+
+ /**
+ * Test Insert account via inline parameters
+ */
+ function testInsertAccountViaInlineParameters()
+ {
+ $this->initScript('account-init.sql');
+ $account= new Account();
+
+ $account->setId(10);
+ $account->setFirstName("Luky");
+ $account->setLastName("Luke");
+ $account->setEmailAddress("luly.luke@somewhere.com");
+
+ $this->sqlmap->Insert("InsertAccountViaInlineParameters", $account);
+
+ $testAccount = $this->sqlmap->QueryForObject("GetAccountViaColumnIndex", 10);
+
+ $this->assertNotNull($testAccount);
+ $this->assertIdentical(10, $testAccount->getId());
+ $this->initScript('account-init.sql');
+ }
+
+ /**
+ * Test Insert account via parameterMap
+ */
+ function testInsertAccountViaParameterMap()
+ {
+ $this->initScript('account-init.sql');
+ $account= $this->NewAccount6();
+ $this->sqlmap->Insert("InsertAccountViaParameterMap", $account);
+
+ $account = $this->sqlmap->QueryForObject("GetAccountNullableEmail", 6);
+ $this->AssertAccount6($account);
+
+ $this->initScript('account-init.sql');
+ }
+
+ /**
+ * Test Update via parameterMap
+ */
+ function testUpdateViaParameterMap()
+ {
+ $this->initScript('account-init.sql');
+ $account= $this->sqlmap->QueryForObject("GetAccountViaColumnName", 1);
+
+ $account->setEmailAddress("new@somewhere.com");
+ $this->sqlmap->Update("UpdateAccountViaParameterMap", $account);
+
+ $account = $this->sqlmap->QueryForObject("GetAccountViaColumnName", 1);
+
+ $this->assertIdentical("new@somewhere.com", $account->getEmailAddress());
+ $this->initScript('account-init.sql');
+ }
+
+ /**
+ * Test Update via parameterMap V2
+ */
+ function testUpdateViaParameterMap2()
+ {
+ $this->initScript('account-init.sql');
+ $account= $this->sqlmap->QueryForObject("GetAccountViaColumnName", 1);
+
+ $account->setEmailAddress("new@somewhere.com");
+ $this->sqlmap->Update("UpdateAccountViaParameterMap2", $account);
+
+ $account = $this->sqlmap->QueryForObject("GetAccountViaColumnName", 1);
+
+ $this->assertIdentical("new@somewhere.com", $account->getEmailAddress());
+ $this->initScript('account-init.sql');
+ }
+
+ /**
+ * Test Update with inline parameters
+ */
+ function testUpdateWithInlineParameters()
+ {
+ $this->initScript('account-init.sql');
+ $account= $this->sqlmap->QueryForObject("GetAccountViaColumnName", 1);
+
+ $account->setEmailAddress("new@somewhere.com");
+ $this->sqlmap->Update("UpdateAccountViaInlineParameters", $account);
+
+ $account = $this->sqlmap->QueryForObject("GetAccountViaColumnName", 1);
+
+ $this->assertIdentical("new@somewhere.com", $account->getEmailAddress());
+ $this->initScript('account-init.sql');
+ }
+
+ /**
+ * Test Execute Update With Parameter Class
+ */
+ function testExecuteUpdateWithParameterClass()
+ {
+ $this->initScript('account-init.sql');
+ $account= $this->NewAccount6();
+
+ $this->sqlmap->Insert("InsertAccountViaParameterMap", $account);
+
+ $noRowsDeleted = $this->sqlmap->Update("DeleteAccount", null);
+
+ $this->sqlmap->Update("DeleteAccount", $account);
+
+ $account = $this->sqlmap->QueryForObject("GetAccountViaColumnName", 6);
+
+ $this->assertNull($account);
+ $this->assertIdentical(0, $noRowsDeleted);
+ $this->initScript('account-init.sql');
+ }
+
+ /**
+ * Test Execute Delete
+ */
+ function testExecuteDelete()
+ {
+ $this->initScript('account-init.sql');
+ $account= $this->NewAccount6();
+
+ $this->sqlmap->Insert("InsertAccountViaParameterMap", $account);
+
+ $account = null;
+ $account = $this->sqlmap->QueryForObject("GetAccountViaColumnName", 6);
+
+ $this->assertTrue($account->getId() == 6);
+
+ $rowNumber = $this->sqlmap->Delete("DeleteAccount", $account);
+ $this->assertTrue($rowNumber == 1);
+
+ $account = $this->sqlmap->QueryForObject("GetAccountViaColumnName", 6);
+
+ $this->assertNull($account);
+ $this->initScript('account-init.sql');
+ }
+
+ /**
+ * Test Execute Delete
+ */
+ function testDeleteWithComments()
+ {
+ $this->initScript('line-item-init.sql');
+ $rowNumber = $this->sqlmap->Delete("DeleteWithComments");
+
+ $this->assertIdentical($rowNumber, 2);
+ $this->initScript('line-item-init.sql');
+ }
+
+
+
+ #endregion
+
+ #region Row delegate
+
+ private $_index = 0;
+
+ function RowHandler($sender, $paramterObject, $list)
+ {
+ //_index++;
+ //$this->assertIdentical(_index, (($account) obj).Id);
+ //$list->Add(obj);
+ }
+
+ #endregion
+
+ #region JIRA Tests
+
+ /**
+ * Test JIRA 30 (repeating property)
+ */
+ function testJIRA30()
+ {
+ $account= new Account();
+ $account->setId(1);
+ $account->setFirstName("Joe");
+ $account->setLastName("Dalton");
+ $account->setEmailAddress("Joe.Dalton@somewhere.com");
+
+ $result = $this->sqlmap->QueryForObject("GetAccountWithRepeatingProperty", $account);
+
+ $this->assertAccount1($result);
+ }
+
+ /**
+ * Test Bit column
+ */
+ function testJIRA42()
+ {
+ $other = new Other();
+
+ $other->setInt(100);
+ $other->setBool(true);
+ $other->setLong(789456321);
+
+ $this->sqlmap->Insert("InsertBool", $other);
+ }
+
+ /**
+ * Test for access a result map in a different namespace
+ */
+ function testJIRA45()
+ {
+ $account= $this->sqlmap->QueryForObject("GetAccountJIRA45", 1);
+ $this->assertAccount1($account);
+ }
+
+ /**
+ * Test : Whitespace is not maintained properly when CDATA tags are used
+ */
+ function testJIRA110()
+ {
+ $account= $this->sqlmap->QueryForObject("Get1Account");
+ $this->assertAccount1($account);
+ }
+
+ /**
+ * Test : Whitespace is not maintained properly when CDATA tags are used
+ */
+ function testJIRA110Bis()
+ {
+ $list = $this->sqlmap->QueryForList("GetAccounts");
+
+ $this->assertAccount1($list[0]);
+ $this->assertIdentical(5, count($list));
+ }
+
+ /**
+ * Test for cache stats only being calculated on CachingStatments
+ */
+ function testJIRA113()
+ {
+ // $this->sqlmap->FlushCaches();
+
+ // taken from TestFlushDataCache()
+ // first query is not cached, second query is: 50% cache hit
+ /*$list = $this->sqlmap->QueryForList("GetCachedAccountsViaResultMap");
+ $firstId = HashCodeProvider.GetIdentityHashCode(list);
+ list = $this->sqlmap->QueryForList("GetCachedAccountsViaResultMap");
+ int secondId = HashCodeProvider.GetIdentityHashCode(list);
+ $this->assertIdentical(firstId, secondId);
+
+ string cacheStats = $this->sqlmap->GetDataCacheStats();
+
+ $this->assertNotNull(cacheStats);*/
+ }
+
+ #endregion
+
+ #region CustomTypeHandler tests
+
+ /**
+ * Test CustomTypeHandler
+ */
+ function testExecuteQueryWithCustomTypeHandler()
+ {
+ $this->sqlmap->registerTypeHandler(new HundredsBool());
+ $this->sqlmap->registerTypeHandler(new OuiNonBool());
+
+ $list = $this->sqlmap->QueryForList("GetAllAccountsViaCustomTypeHandler");
+
+ $this->assertAccount1($list[0]);
+ $this->assertIdentical(5, count($list));
+ $this->assertIdentical(1, $list[0]->getID());
+ $this->assertIdentical(2, $list[1]->getID());
+ $this->assertIdentical(3, $list[2]->getID());
+ $this->assertIdentical(4, $list[3]->getID());
+ $this->assertIdentical(5, $list[4]->getID());
+
+ $this->assertFalse($list[0]->getCartOptions());
+ $this->assertFalse($list[1]->getCartOptions());
+ $this->assertTrue($list[2]->getCartOptions());
+ $this->assertTrue($list[3]->getCartOptions());
+ $this->assertTrue($list[4]->getCartOptions());
+
+ $this->assertTrue($list[0]->getBannerOptions());
+ $this->assertTrue($list[1]->getBannerOptions());
+ $this->assertFalse($list[2]->getBannerOptions());
+ $this->assertFalse($list[3]->getBannerOptions());
+ $this->assertTrue($list[4]->getBannerOptions());
+ }
+
+ /**
+ * Test CustomTypeHandler Oui/Non
+ */
+ function testCustomTypeHandler()
+ {
+ $this->initScript('other-init.sql');
+ $this->initScript('account-init.sql');
+
+ $this->sqlmap->registerTypeHandler(new OuiNonBool());
+
+ $other = new Other();
+ $other->setInt(99);
+ $other->setLong(1966);
+ $other->setBool(true);
+ $other->setBool2(false);
+ $this->sqlmap->Insert("InsertCustomTypeHandler", $other);
+
+ $anOther = $this->sqlmap->QueryForObject("SelectByInt", 99);
+ $this->assertNotNull( $anOther );
+ $this->assertIdentical(99, (int)$anOther->getInt());
+ $this->assertIdentical(1966, (int)$anOther->getLong());
+ $this->assertIdentical(true, (boolean)$anOther->getBool());
+ $this->assertIdentical(false, (boolean)$anOther->getBool2());
+
+ }
+
+ /**
+ * Test CustomTypeHandler Oui/Non
+ */
+ function testInsertInlineCustomTypeHandlerV1()
+ {
+ $this->initScript('other-init.sql');
+ $this->initScript('account-init.sql');
+
+ $other = new Other();
+ $other->setInt(99);
+ $other->setLong(1966);
+ $other->setBool(true);
+ $other->setBool2(false);
+
+ $this->sqlmap->Insert("InsertInlineCustomTypeHandlerV1", $other);
+
+ $anOther = $this->sqlmap->QueryForObject("SelectByIntV1", 99);
+
+ $this->assertNotNull( $anOther );
+ $this->assertIdentical(99, (int)$anOther->getInt());
+ $this->assertIdentical(1966, (int)$anOther->getLong());
+ $this->assertIdentical(true, (boolean)$anOther->getBool());
+ $this->assertIdentical(false, (boolean)$anOther->getBool2());
+
+ }
+
+ /**
+ * Test CustomTypeHandler Oui/Non
+ */
+ function testInsertInlineCustomTypeHandlerV2()
+ {
+ $this->initScript('other-init.sql');
+ $this->initScript('account-init.sql');
+
+ $other = new Other();
+ $other->setInt(99);
+ $other->setLong(1966);
+ $other->setBool(true);
+ $other->setBool2(false);
+
+ $this->sqlmap->Insert("InsertInlineCustomTypeHandlerV2", $other);
+
+ $anOther = $this->sqlmap->QueryForObject("SelectByInt", 99);
+
+ $this->assertNotNull( $anOther );
+ $this->assertIdentical(99, (int)$anOther->getInt());
+ $this->assertIdentical(1966, (int)$anOther->getLong());
+ $this->assertIdentical(true, (boolean)$anOther->getBool());
+ $this->assertIdentical(false, (boolean)$anOther->getBool2());
+ }
+ #endregion
+ /**/
+}
diff --git a/tests/unit/Data/SqlMap/TestQueryForMap.php b/tests/unit/Data/SqlMap/TestQueryForMap.php
new file mode 100644
index 00000000..09810489
--- /dev/null
+++ b/tests/unit/Data/SqlMap/TestQueryForMap.php
@@ -0,0 +1,44 @@
+<?php
+require_once(dirname(__FILE__).'/BaseCase.php');
+
+/**
+ * @package System.Data.SqlMap
+ */
+class TestQueryForMap extends BaseCase
+{
+ function __construct()
+ {
+ parent::__construct();
+ $this->initSqlMap();
+ }
+
+ /**
+ * Test ExecuteQueryForMap : Hashtable.
+ */
+ function testExecuteQueryForMap()
+ {
+ $map = $this->sqlmap->QueryForMap("GetAllAccountsViaResultClass", null, "FirstName",null,0,2);
+ $this->assertIdentical(2, count($map));
+ $this->assertAccount1($map["Joe"]);
+
+ $this->assertIdentical(1, $map["Joe"]->getID());
+ $this->assertIdentical(2, $map["Averel"]->getID());
+ }
+
+ /**
+ * Test ExecuteQueryForMap with value property :
+ * "FirstName" as key, "EmailAddress" as value
+ */
+ function testExecuteQueryForMapWithValueProperty()
+ {
+ $map = $this->sqlmap->QueryForMap("GetAllAccountsViaResultClass", null,
+ "FirstName", "EmailAddress",1,3);
+
+ $this->assertIdentical(3, count($map));
+
+ $this->assertIdentical("Averel.Dalton@somewhere.com", $map["Averel"]);
+ $this->assertNull($map["William"]);
+ $this->assertIdentical("Jack.Dalton@somewhere.com", $map["Jack"]);
+ }
+
+}
diff --git a/tests/unit/Data/SqlMap/Ticket589Test.php b/tests/unit/Data/SqlMap/Ticket589Test.php
new file mode 100644
index 00000000..a648e74f
--- /dev/null
+++ b/tests/unit/Data/SqlMap/Ticket589Test.php
@@ -0,0 +1,23 @@
+<?php
+
+Prado::using('System.Data.SqlMap.TSqlMapManager');
+
+/**
+ * @package System.Data.SqlMap
+ */
+class Ticket589Test extends PHPUnit_Framework_TestCase
+{
+ function test()
+ {
+ $manager = new TSqlMapManager();
+ try
+ {
+ $manager->configureXml(dirname(__FILE__).'/sqlmap.xml');
+ $this->fail();
+ }catch(TSqlMapConfigurationException $e)
+ {
+ $expect = 'Invalid property \'parametrClass\' for class \'TSqlMapStatement\' for tag \'<statement id="findNotVisitedWatchedTopicList"';
+ $this->assertEqual(strpos($e->getMessage(),$expect),0);
+ }
+ }
+}
diff --git a/tests/unit/Data/SqlMap/common.php b/tests/unit/Data/SqlMap/common.php
new file mode 100644
index 00000000..020a296b
--- /dev/null
+++ b/tests/unit/Data/SqlMap/common.php
@@ -0,0 +1,153 @@
+<?php
+
+Prado::using('System.Data.TDbConnection');
+
+if(!defined('SQLMAP_TESTS'))
+ define('SQLMAP_TESTS', realpath(dirname(__FILE__)));
+
+if(!class_exists('Account', false))
+{
+ include(SQLMAP_TESTS.'/domain/A.php');
+ include(SQLMAP_TESTS.'/domain/Account.php');
+ include(SQLMAP_TESTS.'/domain/AccountBis.php');
+ include(SQLMAP_TESTS.'/domain/AccountCollection.php');
+ include(SQLMAP_TESTS.'/domain/B.php');
+ include(SQLMAP_TESTS.'/domain/Document.php');
+ include(SQLMAP_TESTS.'/domain/Book.php');
+ include(SQLMAP_TESTS.'/domain/C.php');
+ include(SQLMAP_TESTS.'/domain/Category.php');
+ include(SQLMAP_TESTS.'/domain/Complex.php');
+ include(SQLMAP_TESTS.'/domain/D.php');
+ include(SQLMAP_TESTS.'/domain/DocumentCollection.php');
+ include(SQLMAP_TESTS.'/domain/E.php');
+ include(SQLMAP_TESTS.'/domain/F.php');
+ include(SQLMAP_TESTS.'/domain/LineItem.php');
+ include(SQLMAP_TESTS.'/domain/LineItemCollection.php');
+ include(SQLMAP_TESTS.'/domain/Newspaper.php');
+ include(SQLMAP_TESTS.'/domain/Order.php');
+ include(SQLMAP_TESTS.'/domain/Other.php');
+ include(SQLMAP_TESTS.'/domain/Sample.php');
+ include(SQLMAP_TESTS.'/domain/Search.php');
+ include(SQLMAP_TESTS.'/domain/User.php');
+}
+
+class DefaultScriptRunner
+{
+ function runScript($connection, $script)
+ {
+ $sql = file_get_contents($script);
+ $lines = explode(';', $sql);
+ foreach($lines as $line)
+ {
+ $line = trim($line);
+ if(strlen($line) > 0)
+ $connection->createCommand($line)->execute();
+ }
+ }
+}
+
+class CopyFileScriptRunner
+{
+ protected $baseFile;
+ protected $targetFile;
+
+ public function __construct($base, $target)
+ {
+ $this->baseFile = $base;
+ $this->targetFile = $target;
+ }
+
+ function runScript($connection, $script)
+ {
+ copy($this->baseFile, $this->targetFile);
+ }
+}
+
+class SQLiteBaseTestConfig extends BaseTestConfig
+{
+ protected $baseFile;
+ protected $targetFile;
+
+ public function __construct()
+ {
+ $this->_sqlmapConfigFile = SQLMAP_TESTS.'/sqlite.xml';
+ $this->_scriptDir = SQLMAP_TESTS.'/scripts/sqlite/';
+
+ $this->targetFile = realpath(SQLMAP_TESTS.'/sqlite/tests.db');
+ $this->baseFile = realpath(SQLMAP_TESTS.'/sqlite/backup.db');
+ $file = realpath($this->targetFile);
+ $this->_connection = new TDbConnection("sqlite:{$file}");
+ }
+
+ public function getScriptRunner()
+ {
+ return new CopyFileScriptRunner($this->baseFile, $this->targetFile);
+ }
+}
+
+class MySQLBaseTestConfig extends BaseTestConfig
+{
+ public function __construct()
+ {
+ $this->_sqlmapConfigFile = SQLMAP_TESTS.'/mysql.xml';
+ $this->_scriptDir = SQLMAP_TESTS.'/scripts/mysql/';
+ $this->_features = array('insert_id');
+ $dsn = 'mysql:host=localhost;dbname=sqlmap_test;port=3307';
+ $this->_connection = new TDbConnection($dsn, 'test5', 'test5');
+ }
+}
+
+class MSSQLBaseTestConfig extends BaseTestConfig
+{
+ public function __construct()
+ {
+ $this->_sqlmap = SQLMAP_TESTS.'/mssql.xml';
+ $this->_connectionString = 'odbc_mssql://sqlmap_tests';
+ $this->_scriptDir = SQLMAP_TESTS.'/scripts/mssql/';
+ $this->_features = array('insert_id');
+ }
+}
+
+class BaseTestConfig
+{
+ protected $_scriptDir;
+ protected $_connection;
+ protected $_sqlmapConfigFile;
+
+ public function hasFeature($type)
+ {
+ return false;
+ }
+
+ public function getScriptDir()
+ {
+ return $this->_scriptDir;
+ }
+
+ public function getConnection()
+ {
+ return $this->_connection;
+ }
+
+ public function getSqlMapConfigFile()
+ {
+ return $this->_sqlmapConfigFile;
+ }
+
+ public function getScriptRunner()
+ {
+ return new DefaultScriptRunner();
+ }
+
+ public static function createConfigInstance()
+ {
+ //change this to connection to a different database
+
+ //return new MySQLBaseTestConfig();
+
+ return new SQLiteBaseTestConfig();
+
+ //return new MSSQLBaseTestConfig();
+ }
+}
+
diff --git a/tests/unit/Data/SqlMap/domain/A.php b/tests/unit/Data/SqlMap/domain/A.php
new file mode 100644
index 00000000..a4f204e4
--- /dev/null
+++ b/tests/unit/Data/SqlMap/domain/A.php
@@ -0,0 +1,25 @@
+<?php
+
+class A
+{
+ private $_ID='';
+ private $_Libelle='';
+ private $_B='';
+ private $_E='';
+ private $_F='';
+
+ public function getID(){ return $this->_ID; }
+ public function setID($value){ $this->_ID = $value; }
+
+ public function getLibelle(){ return $this->_Libelle; }
+ public function setLibelle($value){ $this->_Libelle = $value; }
+
+ public function getB(){ return $this->_B; }
+ public function setB($value){ $this->_B = $value; }
+
+ public function getE(){ return $this->_E; }
+ public function setE($value){ $this->_E = $value; }
+
+ public function getF(){ return $this->_F; }
+ public function setF($value){ $this->_F = $value; }
+}
diff --git a/tests/unit/Data/SqlMap/domain/Account.php b/tests/unit/Data/SqlMap/domain/Account.php
new file mode 100644
index 00000000..b4bcbcc8
--- /dev/null
+++ b/tests/unit/Data/SqlMap/domain/Account.php
@@ -0,0 +1,34 @@
+<?php
+
+class Account
+{
+ private $_ID=0;
+ private $_FirstName='';
+ private $_LastName='';
+ private $_EmailAddress=null;
+ private $_IDS='';
+ private $_BannerOptions=0;
+ private $_CartOptions=0;
+
+ public function getID(){ return $this->_ID; }
+ public function setID($value){ $this->_ID = intval($value); }
+
+ public function getFirstName(){ return $this->_FirstName; }
+ public function setFirstName($value){ $this->_FirstName = $value; }
+
+ public function getLastName(){ return $this->_LastName; }
+ public function setLastName($value){ $this->_LastName = $value; }
+
+ public function getEmailAddress(){ return $this->_EmailAddress; }
+ public function setEmailAddress($value){ $this->_EmailAddress = $value; }
+
+ public function getIDS(){ return $this->_IDS; }
+ public function setIDS($value){ $this->_IDS = $value; }
+
+ public function getBannerOptions(){ return $this->_BannerOptions; }
+ public function setBannerOptions($value){ $this->_BannerOptions = $value; }
+
+ public function getCartOptions(){ return $this->_CartOptions; }
+ public function setCartOptions($value){ $this->_CartOptions = $value; }
+
+}
diff --git a/tests/unit/Data/SqlMap/domain/AccountBis.php b/tests/unit/Data/SqlMap/domain/AccountBis.php
new file mode 100644
index 00000000..e48184b6
--- /dev/null
+++ b/tests/unit/Data/SqlMap/domain/AccountBis.php
@@ -0,0 +1,11 @@
+<?php
+
+class AccountBis
+{
+ public $Id;
+ public $FirstName;
+ public $LastName;
+ public $EmailAddress;
+ public $More;
+}
+
diff --git a/tests/unit/Data/SqlMap/domain/AccountCollection.php b/tests/unit/Data/SqlMap/domain/AccountCollection.php
new file mode 100644
index 00000000..06e30dc8
--- /dev/null
+++ b/tests/unit/Data/SqlMap/domain/AccountCollection.php
@@ -0,0 +1,15 @@
+<?php
+
+class AccountCollection extends TList
+{
+ public function addRange($accounts)
+ {
+ foreach($accounts as $account)
+ $this->add($account);
+ }
+
+ public function copyTo(TList $array)
+ {
+ $array->copyFrom($this);
+ }
+}
diff --git a/tests/unit/Data/SqlMap/domain/B.php b/tests/unit/Data/SqlMap/domain/B.php
new file mode 100644
index 00000000..ab42e6b6
--- /dev/null
+++ b/tests/unit/Data/SqlMap/domain/B.php
@@ -0,0 +1,21 @@
+<?php
+
+class B
+{
+ private $_C='';
+ private $_D='';
+ private $_ID='';
+ private $_Libelle='';
+
+ public function getC(){ return $this->_C; }
+ public function setC($value){ $this->_C = $value; }
+
+ public function getD(){ return $this->_D; }
+ public function setD($value){ $this->_D = $value; }
+
+ public function getID(){ return $this->_ID; }
+ public function setID($value){ $this->_ID = $value; }
+
+ public function getLibelle(){ return $this->_Libelle; }
+ public function setLibelle($value){ $this->_Libelle = $value; }
+}
diff --git a/tests/unit/Data/SqlMap/domain/Book.php b/tests/unit/Data/SqlMap/domain/Book.php
new file mode 100644
index 00000000..4c0670e8
--- /dev/null
+++ b/tests/unit/Data/SqlMap/domain/Book.php
@@ -0,0 +1,9 @@
+<?php
+
+class Book extends Document
+{
+ private $_PageNumber='';
+
+ public function getPageNumber(){ return $this->_PageNumber; }
+ public function setPageNumber($value){ $this->_PageNumber = $value; }
+}
diff --git a/tests/unit/Data/SqlMap/domain/C.php b/tests/unit/Data/SqlMap/domain/C.php
new file mode 100644
index 00000000..642f97e9
--- /dev/null
+++ b/tests/unit/Data/SqlMap/domain/C.php
@@ -0,0 +1,13 @@
+<?php
+
+class C
+{
+ private $_ID='';
+ private $_Libelle='';
+
+ public function getID(){ return $this->_ID; }
+ public function setID($value){ $this->_ID = $value; }
+
+ public function getLibelle(){ return $this->_Libelle; }
+ public function setLibelle($value){ $this->_Libelle = $value; }
+}
diff --git a/tests/unit/Data/SqlMap/domain/Category.php b/tests/unit/Data/SqlMap/domain/Category.php
new file mode 100644
index 00000000..895819e9
--- /dev/null
+++ b/tests/unit/Data/SqlMap/domain/Category.php
@@ -0,0 +1,17 @@
+<?php
+
+class Category
+{
+ private $_ID=-1;
+ private $_Name='';
+ private $_Guid='';
+
+ public function getID(){ return $this->_ID; }
+ public function setID($value){ $this->_ID = $value; }
+
+ public function getName(){ return $this->_Name; }
+ public function setName($value){ $this->_Name = $value; }
+
+ public function getGuidString(){ return $this->_Guid; }
+ public function setGuidString($value){ $this->_Guid = $value; }
+}
diff --git a/tests/unit/Data/SqlMap/domain/Complex.php b/tests/unit/Data/SqlMap/domain/Complex.php
new file mode 100644
index 00000000..01082343
--- /dev/null
+++ b/tests/unit/Data/SqlMap/domain/Complex.php
@@ -0,0 +1,9 @@
+<?php
+
+class Complex
+{
+ private $_map;
+
+ public function getMap(){ return $this->_map; }
+ public function setMap(TMap $map){ $this->_map = $map; }
+}
diff --git a/tests/unit/Data/SqlMap/domain/D.php b/tests/unit/Data/SqlMap/domain/D.php
new file mode 100644
index 00000000..f120e2d1
--- /dev/null
+++ b/tests/unit/Data/SqlMap/domain/D.php
@@ -0,0 +1,14 @@
+<?php
+
+class D
+{
+ private $_ID='';
+ private $_Libelle='';
+
+ public function getID(){ return $this->_ID; }
+ public function setID($value){ $this->_ID = $value; }
+
+ public function getLibelle(){ return $this->_Libelle; }
+ public function setLibelle($value){ $this->_Libelle = $value; }
+
+}
diff --git a/tests/unit/Data/SqlMap/domain/Document.php b/tests/unit/Data/SqlMap/domain/Document.php
new file mode 100644
index 00000000..518851e6
--- /dev/null
+++ b/tests/unit/Data/SqlMap/domain/Document.php
@@ -0,0 +1,14 @@
+<?php
+
+class Document
+{
+ private $_ID='';
+ private $_Title='';
+
+ public function getID(){ return $this->_ID; }
+ public function setID($value){ $this->_ID = $value; }
+
+ public function getTitle(){ return $this->_Title; }
+ public function setTitle($value){ $this->_Title = $value; }
+
+}
diff --git a/tests/unit/Data/SqlMap/domain/DocumentCollection.php b/tests/unit/Data/SqlMap/domain/DocumentCollection.php
new file mode 100644
index 00000000..a2d5d89d
--- /dev/null
+++ b/tests/unit/Data/SqlMap/domain/DocumentCollection.php
@@ -0,0 +1,6 @@
+<?php
+
+class DocumentCollection extends TList
+{
+
+}
diff --git a/tests/unit/Data/SqlMap/domain/E.php b/tests/unit/Data/SqlMap/domain/E.php
new file mode 100644
index 00000000..c69c8027
--- /dev/null
+++ b/tests/unit/Data/SqlMap/domain/E.php
@@ -0,0 +1,14 @@
+<?php
+
+class E
+{
+ private $_ID='';
+ private $_Libelle='';
+
+ public function getID(){ return $this->_ID; }
+ public function setID($value){ $this->_ID = $value; }
+
+ public function getLibelle(){ return $this->_Libelle; }
+ public function setLibelle($value){ $this->_Libelle = $value; }
+
+}
diff --git a/tests/unit/Data/SqlMap/domain/F.php b/tests/unit/Data/SqlMap/domain/F.php
new file mode 100644
index 00000000..159d8d63
--- /dev/null
+++ b/tests/unit/Data/SqlMap/domain/F.php
@@ -0,0 +1,14 @@
+<?php
+
+class F
+{
+ private $_ID='';
+ private $_Libelle='';
+
+ public function getID(){ return $this->_ID; }
+ public function setID($value){ $this->_ID = $value; }
+
+ public function getLibelle(){ return $this->_Libelle; }
+ public function setLibelle($value){ $this->_Libelle = $value; }
+
+}
diff --git a/tests/unit/Data/SqlMap/domain/LineItem.php b/tests/unit/Data/SqlMap/domain/LineItem.php
new file mode 100644
index 00000000..a989ab8b
--- /dev/null
+++ b/tests/unit/Data/SqlMap/domain/LineItem.php
@@ -0,0 +1,30 @@
+<?php
+
+class LineItem
+{
+ private $_ID=-1;
+ private $_Order='';
+ private $_Code='';
+ private $_Quantity=-1;
+ private $_Price=0.0;
+ private $_PictureData='';
+
+ public function getID(){ return $this->_ID; }
+ public function setID($value){ $this->_ID = $value; }
+
+ public function getOrder(){ return $this->_Order; }
+ public function setOrder($value){ $this->_Order = $value; }
+
+ public function getCode(){ return $this->_Code; }
+ public function setCode($value){ $this->_Code = $value; }
+
+ public function getQuantity(){ return $this->_Quantity; }
+ public function setQuantity($value){ $this->_Quantity = $value; }
+
+ public function getPrice(){ return $this->_Price; }
+ public function setPrice($value){ $this->_Price = $value; }
+
+ public function getPictureData(){ return $this->_PictureData; }
+ public function setPictureData($value){ $this->_PictureData = $value; }
+
+}
diff --git a/tests/unit/Data/SqlMap/domain/LineItemCollection.php b/tests/unit/Data/SqlMap/domain/LineItemCollection.php
new file mode 100644
index 00000000..1c31dca3
--- /dev/null
+++ b/tests/unit/Data/SqlMap/domain/LineItemCollection.php
@@ -0,0 +1,6 @@
+<?php
+
+class LineItemCollection extends TList
+{
+
+}
diff --git a/tests/unit/Data/SqlMap/domain/Newspaper.php b/tests/unit/Data/SqlMap/domain/Newspaper.php
new file mode 100644
index 00000000..12ebce5b
--- /dev/null
+++ b/tests/unit/Data/SqlMap/domain/Newspaper.php
@@ -0,0 +1,10 @@
+<?php
+
+class Newspaper extends Document
+{
+ private $_City='';
+
+ public function getCity(){ return $this->_City; }
+ public function setCity($value){ $this->_City = $value; }
+
+}
diff --git a/tests/unit/Data/SqlMap/domain/Order.php b/tests/unit/Data/SqlMap/domain/Order.php
new file mode 100644
index 00000000..2b907ac6
--- /dev/null
+++ b/tests/unit/Data/SqlMap/domain/Order.php
@@ -0,0 +1,69 @@
+<?php
+
+class Order
+{
+ private $_ID=-1;
+ private $_Account='';
+ private $_Date='';
+ private $_CardType='';
+ private $_CardExpiry='';
+ private $_CardNumber='';
+ private $_Street='';
+ private $_City='';
+ private $_Province='';
+ private $_PostalCode='';
+ private $_LineItemsList='';
+ private $_LineItems=null;
+ private $_LineItemsArray=array();
+ private $_FavouriteLineItem=null;
+
+ public function __construct()
+ {
+ $this->_LineItemsList = new TList;
+ $this->_LineItems = new TList;
+ $this->_FavouriteLineItem = new LineItem;
+ }
+
+ public function getID(){ return $this->_ID; }
+ public function setID($value){ $this->_ID = $value; }
+
+ public function getAccount(){ return $this->_Account; }
+ public function setAccount($value){ $this->_Account = $value; }
+
+ public function getDate(){ return $this->_Date; }
+ public function setDate($value){ $this->_Date = $value; }
+
+ public function getCardType(){ return $this->_CardType; }
+ public function setCardType($value){ $this->_CardType = $value; }
+
+ public function getCardExpiry(){ return $this->_CardExpiry; }
+ public function setCardExpiry($value){ $this->_CardExpiry = $value; }
+
+ public function getCardNumber(){ return $this->_CardNumber; }
+ public function setCardNumber($value){ $this->_CardNumber = $value; }
+
+ public function getStreet(){ return $this->_Street; }
+ public function setStreet($value){ $this->_Street = $value; }
+
+ public function getCity(){ return $this->_City; }
+ public function setCity($value){ $this->_City = $value; }
+
+ public function getProvince(){ return $this->_Province; }
+ public function setProvince($value){ $this->_Province = $value; }
+
+ public function getPostalCode(){ return $this->_PostalCode; }
+ public function setPostalCode($value){ $this->_PostalCode = $value; }
+
+ public function getLineItemsList(){ return $this->_LineItemsList; }
+ public function setLineItemsList($value){ $this->_LineItemsList = $value; }
+
+ public function getLineItems(){ return $this->_LineItems; }
+ public function setLineItems($value){ $this->_LineItems = $value; }
+
+ public function getLineItemsArray(){ return $this->_LineItemsArray; }
+ public function setLineItemsArray($value){ $this->_LineItemsArray = $value; }
+
+ public function getFavouriteLineItem(){ return $this->_FavouriteLineItem; }
+ public function setFavouriteLineItem($value){ $this->_FavouriteLineItem = $value; }
+
+}
diff --git a/tests/unit/Data/SqlMap/domain/Other.php b/tests/unit/Data/SqlMap/domain/Other.php
new file mode 100644
index 00000000..89f9d490
--- /dev/null
+++ b/tests/unit/Data/SqlMap/domain/Other.php
@@ -0,0 +1,21 @@
+<?php
+
+class Other
+{
+ private $_Int=-1;
+ private $_Long=-1;
+ private $_Bool=false;
+ private $_Bool2=false;
+
+ public function getBool2(){ return $this->_Bool2; }
+ public function setBool2($value){ $this->_Bool2 = $value; }
+
+ public function getBool(){ return $this->_Bool; }
+ public function setBool($value){ $this->_Bool = $value; }
+
+ public function getInt(){ return $this->_Int; }
+ public function setInt($value){ $this->_Int = $value; }
+
+ public function getLong(){ return $this->_Long; }
+ public function setLong($value){ $this->_Long = $value; }
+}
diff --git a/tests/unit/Data/SqlMap/domain/Sample.php b/tests/unit/Data/SqlMap/domain/Sample.php
new file mode 100644
index 00000000..f2a8951f
--- /dev/null
+++ b/tests/unit/Data/SqlMap/domain/Sample.php
@@ -0,0 +1,53 @@
+<?php
+
+class Sample
+{
+ private $_FirstID='';
+ private $_SecondID='';
+ private $_ThirdID='';
+ private $_FourthID='';
+ private $_FifthID='';
+ private $_SequenceID='';
+ private $_DistributedID='';
+ private $_SampleChar='';
+ private $_SampleDecimal='';
+ private $_SampleMoney='';
+ private $_SampleDate='';
+ private $_SequenceDate='';
+
+ public function getFirstID(){ return $this->_FirstID; }
+ public function setFirstID($value){ $this->_FirstID = $value; }
+
+ public function getSecondID(){ return $this->_SecondID; }
+ public function setSecondID($value){ $this->_SecondID = $value; }
+
+ public function getThirdID(){ return $this->_ThirdID; }
+ public function setThirdID($value){ $this->_ThirdID = $value; }
+
+ public function getFourthID(){ return $this->_FourthID; }
+ public function setFourthID($value){ $this->_FourthID = $value; }
+
+ public function getFifthID(){ return $this->_FifthID; }
+ public function setFifthID($value){ $this->_FifthID = $value; }
+
+ public function getSequenceID(){ return $this->_SequenceID; }
+ public function setSequenceID($value){ $this->_SequenceID = $value; }
+
+ public function getDistributedID(){ return $this->_DistributedID; }
+ public function setDistributedID($value){ $this->_DistributedID = $value; }
+
+ public function getSampleChar(){ return $this->_SampleChar; }
+ public function setSampleChar($value){ $this->_SampleChar = $value; }
+
+ public function getSampleDecimal(){ return $this->_SampleDecimal; }
+ public function setSampleDecimal($value){ $this->_SampleDecimal = $value; }
+
+ public function getSampleMoney(){ return $this->_SampleMoney; }
+ public function setSampleMoney($value){ $this->_SampleMoney = $value; }
+
+ public function getSampleDate(){ return $this->_SampleDate; }
+ public function setSampleDate($value){ $this->_SampleDate = $value; }
+
+ public function getSequenceDate(){ return $this->_SequenceDate; }
+ public function setSequenceDate($value){ $this->_SequenceDate = $value; }
+}
diff --git a/tests/unit/Data/SqlMap/domain/Search.php b/tests/unit/Data/SqlMap/domain/Search.php
new file mode 100644
index 00000000..d2170044
--- /dev/null
+++ b/tests/unit/Data/SqlMap/domain/Search.php
@@ -0,0 +1,21 @@
+<?php
+
+class Search
+{
+ private $_NumberSearch='';
+ private $_StartDate='';
+ private $_Operande='';
+ private $_StartDateAnd='';
+
+ public function getNumberSearch(){ return $this->_NumberSearch; }
+ public function setNumberSearch($value){ $this->_NumberSearch = $value; }
+
+ public function getStartDate(){ return $this->_StartDate; }
+ public function setStartDate($value){ $this->_StartDate = $value; }
+
+ public function getOperande(){ return $this->_Operande; }
+ public function setOperande($value){ $this->_Operande = $value; }
+
+ public function getStartDateAnd(){ return $this->_StartDateAnd; }
+ public function setStartDateAnd($value){ $this->_StartDateAnd = $value; }
+}
diff --git a/tests/unit/Data/SqlMap/domain/User.php b/tests/unit/Data/SqlMap/domain/User.php
new file mode 100644
index 00000000..1106d1e9
--- /dev/null
+++ b/tests/unit/Data/SqlMap/domain/User.php
@@ -0,0 +1,25 @@
+<?php
+
+class User
+{
+ private $_ID='';
+ private $_UserName='';
+ private $_Password='';
+ private $_EmailAddress='';
+ private $_LastLogon='';
+
+ public function getID(){ return $this->_ID; }
+ public function setID($value){ $this->_ID = $value; }
+
+ public function getUserName(){ return $this->_UserName; }
+ public function setUserName($value){ $this->_UserName = $value; }
+
+ public function getPassword(){ return $this->_Password; }
+ public function setPassword($value){ $this->_Password = $value; }
+
+ public function getEmailAddress(){ return $this->_EmailAddress; }
+ public function setEmailAddress($value){ $this->_EmailAddress = $value; }
+
+ public function getLastLogon(){ return $this->_LastLogon; }
+ public function setLastLogon($value){ $this->_LastLogon = $value; }
+}
diff --git a/tests/unit/Data/SqlMap/gen.php b/tests/unit/Data/SqlMap/gen.php
new file mode 100644
index 00000000..40ddc297
--- /dev/null
+++ b/tests/unit/Data/SqlMap/gen.php
@@ -0,0 +1,31 @@
+<?php
+
+$props = <<<EOD
+_prepend
+_property
+_compareProperty
+_compareValue
+EOD;
+
+print_vars($props);
+echo "\n";
+print_funcs($props);
+
+function print_vars($props)
+{
+ foreach(explode("\n", $props) as $prop)
+ {
+ echo "\tprivate \${$prop};\n";
+ }
+}
+
+function print_funcs($props)
+{
+ foreach(explode("\n", $props) as $prop)
+ {
+ $name = ucfirst(str_replace('_', '', $prop));
+ $getter = "\tpublic function get{$name}(){ return \$this->{$prop}; }\n";
+ $setter = "\tpublic function set{$name}(\$value){ \$this->{$prop} = \$value; }\n";
+ echo $getter.$setter."\n";
+ }
+}
diff --git a/tests/unit/Data/SqlMap/maps/MySql/Account.xml b/tests/unit/Data/SqlMap/maps/MySql/Account.xml
new file mode 100644
index 00000000..d6dd1c1d
--- /dev/null
+++ b/tests/unit/Data/SqlMap/maps/MySql/Account.xml
@@ -0,0 +1,624 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<sqlMap namespace="Account" >
+
+ <!-- =============================================
+ <resultMap
+ name="name"
+ class="name"
+ extend="resultMapId"
+ >
+ <result
+ property="name"
+ column="name"
+ columnIndex="name"
+ nullValue="value"
+ select="name"
+ resultMap="name"
+ lazyLoad="true/false"
+ dbType=""
+ />
+ <procedure
+ name="name"
+ parameterMap="name"
+ >
+ <statement
+ name="name"
+ parameterClass="name"
+ parameterMap="name"
+ resultClass="name"
+ resultMap="name"
+ listClass="name"
+ >
+ <parameterMap
+ name="name"
+ class=""
+ >
+ <parameter
+ property="name"
+ dbType=""
+ output="true/false"
+ type=""
+ nullValue=""
+ extend="parameterMapId"
+ />
+
+ ============================================= -->
+
+ <cacheModel id="account-cache" implementation="LRU" >
+ <flushInterval hours="24"/>
+ <flushOnExecute statement="UpdateAccountViaInlineParameters"/>
+ <flushOnExecute statement="UpdateAccountViaParameterMap"/>
+ <property name="size" value="10"/>
+ </cacheModel>
+
+ <!--
+ <cacheModel name="account-cache" implementation="LRU" >
+ <flushInterval hours="24"/>
+ <flushOnExecute statement="UpdateAccountViaInlineParameters"/>
+ <flushOnExecute statement="UpdateAccountViaParameterMap"/>
+ <property name="CacheSize" value="50"/>
+ </cacheModel>
+ -->
+
+
+ <alias>
+ <typeAlias alias="HundredsBool" type="IBatisNet.DataMapper.Test.Domain.HundredsTypeHandlerCallback, IBatisNet.DataMapper.Test"/>
+ </alias>
+
+ <resultMap id="account-result" class="Account" >
+ <result property="Id" column="Account_Id"/>
+ <result property="FirstName" column="Account_FirstName"/>
+ <result property="LastName" column="Account_LastName"/>
+ <result property="EmailAddress" column="Account_Email" nullValue="no_email@provided.com"/>
+ <result property="BannerOptions" column="Account_Banner_Option" typeHandler="OuiNonBool"/>
+ <result property="CartOptions" column="Account_Cart_Option" typeHandler="HundredsBool"/>
+ </resultMap>
+ <resultMap id="indexed-account-result" class="Account">
+ <result property="Id" column="Account_Id" columnIndex="0"/>
+ <result property="FirstName" column="Account_FirstName" columnIndex="1"/>
+ <result property="LastName" column="Account_LastName" columnIndex="2"/>
+ <result property="EmailAddress" column="Account_Email" columnIndex="3" nullValue="no_email@provided.com"/>
+ </resultMap>
+ <resultMap id="account-result-nullable-email" class="Account">
+ <result property="Id" column="Account_Id"/>
+ <result property="FirstName" column="Account_FirstName"/>
+ <result property="LastName" column="Account_LastName"/>
+ <result property="EmailAddress" column="Account_Email"/>
+ </resultMap>
+
+ <resultMap id="email-result" class="string">
+ <result property="value" column="Account_Email"/>
+ </resultMap>
+
+ <resultMap id="account-hashtable-result" class="array">
+ <result property="Id" column="Account_Id"/>
+ <result property="FirstName" column="Account_FirstName"/>
+ <result property="LastName" column="Account_LastName"/>
+ <result property="EmailAddress" column="Account_Email"/>
+ </resultMap>
+
+
+ <!-- =============================================
+ MAPPED STATEMENTS - w/Inline Parameters
+ =============================================
+ -->
+
+ <select id="GetAllAccountsAsArrayListViaResultClass"
+ resultClass="TList">
+ select
+ Account_Id as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ order by Account_Id
+ </select>
+
+ <select id="GetAccountsDynamic" resultMap="account-result" parameterClass="Hashtable" >
+ select * from Accounts
+ <dynamic prepend="where">
+ <isParameterPresent>
+ <isNotEmpty prepend="and" property="FirstName" >
+ Account_FirstName LIKE '%$FirstName$%'
+ </isNotEmpty>
+ <isNotEmpty prepend="and" property="LastName" >
+ Account_LastName LIKE '%$LastName$%'
+ </isNotEmpty>
+ <isNotEmpty prepend="and" property="EmailAddress" >
+ Account_Email LIKE '%$EmailAddress$%'
+ </isNotEmpty>
+ </isParameterPresent>
+ </dynamic>
+ order by Account_LastName
+ limit 0, $MaximumAllowed$
+ </select>
+
+ <select id="SelectWithProperty"
+ resultMap="account-result">
+ select *
+ from Accounts
+ where Account_FirstName = ${accountName}
+ </select>
+
+ <select id="GetCachedAccountsViaResultMap"
+ resultMap="account-result"
+ cacheModel="account-cache" >
+ select *
+ from Accounts
+ order by Account_Id
+ </select>
+
+ <select id="GetNoAccountWithCache"
+ parameterClass="Integer"
+ resultMap="account-hashtable-result"
+ cacheModel="account-cache">
+ select *
+ from Accounts
+ where Account_Id = #value#
+ </select>
+
+ <select id="GetAccountAsHashtable"
+ parameterClass="Integer"
+ resultMap="account-hashtable-result">
+ select *
+ from Accounts
+ where Account_Id = #value#
+ </select>
+
+ <select id="GetAllAccountsAsHashMapViaResultMap"
+ resultMap="account-hashtable-result">
+ select *
+ from Accounts
+ order by Account_Id
+ </select>
+
+ <select id="GetAccountAsHashtableResultClass"
+ parameterClass="int"
+ resultClass="array">
+ select
+ Account_Id as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ where Account_Id = #value#
+ </select>
+
+ <select id="GetAllAccountsAsHashtableViaResultClass"
+ resultClass="array">
+ select
+ Account_Id as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ order by Account_Id
+ </select>
+
+ <select id="GetAccountViaColumnName"
+ parameterClass="int"
+ resultMap="account-result">
+ select
+ Account_Id,
+ Account_FirstName,
+ Account_LastName,
+ Account_Email,
+ Account_Banner_Option,
+ Account_Cart_Option
+ from Accounts
+ where Account_Id = #value#
+ </select>
+
+ <select id="GetAccountViaColumnIndex"
+ parameterClass="int"
+ resultMap="indexed-account-result">
+ select
+ Account_Id,
+ Account_FirstName,
+ Account_LastName,
+ Account_Email
+ from Accounts
+ where Account_Id = #value#
+ </select>
+
+ <select id="GetAllAccountsViaResultMap"
+ resultMap="account-result">
+ select * from Accounts
+ order by Account_Id
+ </select>
+
+ <select id="GetAllAccountsViaResultClass"
+ resultClass="Account">
+ select
+ Account_Id as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ order by Account_Id
+ </select>
+
+ <select id="GetFewAccountsViaResultMap"
+ resultMap="account-result">
+ <![CDATA[
+ select * from Accounts
+ where Account_Id < 2
+ order by Account_Id
+ ]]>
+ </select>
+
+ <select id="GetNoAccountsViaResultMap"
+ resultMap="account-result">
+ select * from Accounts
+ where Account_Id > 1000
+ order by Account_Id
+ </select>
+
+
+ <select id="GetAccountNullableEmail"
+ resultMap="account-result-nullable-email">
+ select
+ Account_Id,
+ Account_FirstName,
+ Account_LastName,
+ Account_Email
+ from Accounts
+ where Account_Id = #value#
+ </select>
+
+ <select id="GetAccountViaResultClass"
+ resultClass="Account">
+ <![CDATA[
+ select
+ Account_Id as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ where Account_Id = #value#
+ ]]>
+ </select>
+
+ <select id="GetAccountViaInlineParameters"
+ resultMap="indexed-account-result">
+ select
+ Account_Id,
+ Account_FirstName,
+ Account_LastName,
+ Account_Email
+ from Accounts
+ where Account_Id = #Id# and Account_Id = #Id#
+ </select>
+
+ <select id="GetEmailAddressViaResultClass" resultClass="string">
+ select Account_Email as value
+ from Accounts
+ where Account_Id = #value#
+ </select>
+
+ <select id="GetEmailAddressViaResultMap"
+ parameterClass="int"
+ resultMap="email-result">
+ select Account_Email
+ from Accounts
+ where Account_Id = #value#
+ </select>
+
+ <select id="GetAllEmailAddressesViaResultClass"
+ resultClass="string">
+ select Account_Email
+ from Accounts
+ order by Account_Id
+ </select>
+
+ <select id="GetAllEmailAddressesViaResultMap"
+ resultMap="email-result">
+ select Account_Email
+ from Accounts
+ order by Account_Id
+ </select>
+
+ <insert id="InsertAccountViaParameterMap"
+ parameterMap="account-insert-params">
+ insert into Accounts
+ (Account_Id, Account_FirstName, Account_LastName, Account_Email, Account_Banner_Option, Account_Cart_Option)
+ values
+ (?, ?, ?, ?, ?, ?)
+ </insert>
+
+ <update id="UpdateAccountViaParameterMap"
+ parameterMap="update-params">
+ update Accounts set
+ Account_FirstName = ?,
+ Account_LastName = ?,
+ Account_Email = ?
+ where
+ Account_Id = ?
+ </update>
+
+ <update id="UpdateAccountViaParameterMap2"
+ parameterMap="update-params2">
+ update Accounts set
+ Account_Id = ?,
+ Account_FirstName = ?,
+ Account_LastName = ?,
+ Account_Email = ?
+ where
+ Account_Id = ?
+ </update>
+
+ <delete id="DeleteAccountViaInlineParameters">
+ delete from Accounts
+ where
+ Account_Id = #Id#
+ </delete>
+
+ <select id="GetAccountComplexMapping"
+ resultMap="indexed-account-result"
+ parameterClass="array">
+ select *
+ from Accounts
+ where
+ Account_FirstName = #Account.FirstName#
+ And Account_LastName = #Order.City#
+ </select>
+
+ <select id="GetDynamicOrderedEmailAddressesViaResultMap"
+ resultMap="email-result">
+ select Account_Email
+ from Accounts
+ order by $value$
+ </select>
+
+ <!-- Dynamic statements -->
+ <select id="GetAllAccountsViaResultMapWithDynamicElement"
+ resultMap="account-result">
+ select * from Accounts
+ where Account_Email $value$ '%@%'
+ order by Account_Id
+ </select>
+
+ <select id="SimpleDynamicSubstitution"
+ parameterClass="Hashtable"
+ resultClass="Account">
+ $statement$
+ </select>
+
+ <!-- Public Fields -->
+ <insert id="InsertAccountViaPublicFields">
+ insert into Accounts
+ (Account_Id, Account_FirstName, Account_LastName, Account_Email)
+ values
+ (#Id#, #FirstName#, #LastName#, #EmailAddress#
+ )
+ </insert>
+
+
+ <!-- Inline Parameters -->
+ <update id="UpdateAccountViaInlineParameters"
+ parameterClass="Account">
+ update Accounts set
+ Account_FirstName = #FirstName#,
+ Account_LastName = #LastName#,
+ Account_Email = #EmailAddress, dbType=VarChar, nullValue=no_email@provided.com#
+ where
+ Account_Id = #Id#
+ </update>
+
+ <insert id="InsertAccountViaInlineParameters"
+ parameterClass="Account" >
+ insert into Accounts
+ (Account_Id, Account_FirstName, Account_LastName, Account_Email)
+ values
+ (#Id#, #FirstName#, #LastName#, #EmailAddress, dbType=VarChar, nullValue=no_email@provided.com#
+ )
+ </insert>
+
+ <insert id="InsertAccountNullableEmail"
+ parameterClass="Account" >
+ insert into Accounts
+ (Account_Id, Account_FirstName, Account_LastName, Account_Email)
+ values
+ ( #Id#, #FirstName#, #LastName#, #EmailAddress, dbType=VarChar# )
+ </insert>
+
+ <insert id="InsertAccountUknownParameterClass">
+ insert into Accounts
+ (Account_Id, Account_FirstName, Account_LastName, Account_Email)
+ values
+ ( #Id#, #FirstName#, #LastName#, #EmailAddress, dbType=VarChar# )
+ </insert>
+
+ <delete id="DeleteAccount"
+ parameterClass="Account">
+ delete from Accounts
+ where Account_Id = #Id#
+ and Account_Id = #Id#
+ </delete>
+
+ <!-- Extends statement -->
+ <select id="GetAllAccounts"
+ resultMap="indexed-account-result">
+ select
+ Account_Id,
+ Account_FirstName,
+ Account_LastName,
+ Account_Email
+ from Accounts
+ </select>
+
+ <select id="GetAllAccountsOrderByName"
+ extends="GetAllAccounts"
+ resultMap="indexed-account-result">
+ order by Account_FirstName
+ </select>
+
+ <select id="GetOneAccount"
+ extends="GetAllAccounts"
+ resultMap="indexed-account-result">
+ where Account_Id = #value#
+ </select>
+
+ <select id="GetSomeAccount"
+ extends="GetAllAccounts"
+ parameterClass="Hashtable"
+ resultMap="indexed-account-result">
+ where Account_Id between #lowID# and #hightID#
+ </select>
+
+ <select id="SelectAccountJIRA29" parameterClass="map" resultClass="Account">
+ select
+ Account_Id as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ where Account_FirstName = '##$AccountName$##'
+ </select>
+
+ <select id="SelectAccountJIRA29-2"
+ parameterClass="Hashtable"
+ resultClass="Account">
+ select
+ Account_Id as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ where 1=1
+ <isNotEmpty prepend="AND" property="Foo">
+ (Account_FirstName = '##$Foo$##')
+ </isNotEmpty>
+ </select>
+
+ <select id="GetAccountWithRepeatingProperty"
+ parameterClass="Account"
+ resultMap="indexed-account-result">
+ select
+ Account_Id,
+ Account_FirstName,
+ Account_LastName,
+ Account_Email
+ from Accounts
+ where Account_Id = #Id# and
+ Account_Id = #Id# and
+ Account_FirstName = #FirstName# and
+ Account_LastName = #LastName# and
+ Account_Id = #Id#
+ </select>
+
+ <select id="GetAllAccountsViaCustomTypeHandler"
+ resultMap="account-result">
+ select * from Accounts
+ order by Account_Id
+ </select>
+
+ <!-- JIRA-110 -->
+ <select id="GetManyAccound" resultClass="Account">
+ SELECT
+ Account_Id as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ FROM Accounts
+ </select>
+
+ <select id="Get1Account" extends="GetManyAccound" resultClass="Account">WHERE Account_Id=1</select>
+
+ <statement id="GetAccounts" resultMap="account-result">
+ SELECT *
+ FROM
+ Accounts
+ </statement>
+ <!-- JIRA-110 -->
+
+ <insert id="InsertAccountDynamic" parameterClass="Account">
+ INSERT INTO Accounts
+ (Account_Id, Account_FirstName, Account_LastName, Account_Email)
+ VALUES(#Id#, #FirstName#, #LastName#
+ <dynamic prepend=",">
+ <isNotNull prepend="," property="EmailAddress">
+ #EmailAddress#
+ </isNotNull>
+ <isNull prepend="," property="EmailAddress">
+ null
+ </isNull>
+ </dynamic>
+ )
+ </insert>
+
+
+ <!-- accounts and orders -->
+
+ <select id="getAccountWithOrders" resultMap="Account-with-Orders">
+ SELECT * FROM Accounts
+ LEFT JOIN Orders ON
+ Accounts.account_id = Orders.account_id
+ </select>
+
+ <resultMap id="Account-with-Orders" class="AccountWithOrders" groupBy="Account_Id">
+ <result property="Id" column="Account_Id"/>
+ <result property="FirstName" column="Account_FirstName"/>
+ <result property="LastName" column="Account_LastName"/>
+ <result property="EmailAddress" column="Account_Email" />
+ <result property="Orders" resultMapping="account-orders" />
+ </resultMap>
+
+ <resultMap id="account-orders" class="Order">
+ <result property="Id" column="Order_Id"/>
+ <result property="Date" type="date" column="Order_Date" nullValue="0001-01-01 00:00:00"/>
+ <result property="CardExpiry" column="Order_CardExpiry"/>
+ <result property="CardType" column="Order_CardType"/>
+ <result property="CardNumber" column="Order_CardNumber"/>
+ <result property="Street" column="Order_Street"/>
+ <result property="City" column="Order_City"/>
+ <result property="Province" column="Order_Province"/>
+ <result property="PostalCode" column="Order_PostalCode"/>
+ </resultMap>
+
+
+ <!-- For procedure, the parameters of the parameterMap must in the same order
+ as for the procedure paramaters-->
+ <procedure id="InsertAccountViaStoreProcedure" parameterMap="account-insert-params">
+ ps_InsertAccount
+ </procedure>
+
+ <procedure id="SwapEmailAddresses" parameterMap="swap-params">
+ ps_swap_email_address
+ </procedure>
+
+ <!-- =============================================
+ OPTIONAL EXPLICIT PARAMETER MAP
+ ============================================= -->
+
+ <parameterMap id="swap-params">
+ <parameter property="email1" column="First_Email" />
+ <parameter property="email2" column="Second_Email" />
+ </parameterMap>
+
+ <parameterMap id="account-insert-params">
+ <parameter property="Id" />
+ <parameter property="FirstName" />
+ <parameter property="LastName" />
+ <parameter property="EmailAddress" nullValue="no_email@provided.com"/>
+ <parameter property="BannerOptions" dbType="Varchar" type="bool"/>
+ <parameter property="CartOptions" column="Account_Cart_Option" typeHandler="HundredsBool"/>
+ </parameterMap>
+
+ <parameterMap id="update-params">
+ <parameter property="FirstName" />
+ <parameter property="LastName" />
+ <parameter property="EmailAddress" nullValue="no_email@provided.com"/>
+ <parameter property="Id" />
+ </parameterMap>
+
+ <parameterMap id="update-params2">
+ <parameter property="Id" />
+ <parameter property="FirstName" />
+ <parameter property="LastName" />
+ <parameter property="EmailAddress" nullValue="no_email@provided.com"/>
+ <parameter property="Id" />
+ </parameterMap>
+
+
+</sqlMap> \ No newline at end of file
diff --git a/tests/unit/Data/SqlMap/maps/MySql/ActiveRecord.xml b/tests/unit/Data/SqlMap/maps/MySql/ActiveRecord.xml
new file mode 100644
index 00000000..1c48010f
--- /dev/null
+++ b/tests/unit/Data/SqlMap/maps/MySql/ActiveRecord.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<sqlMap>
+
+ <select id="GetActiveRecordAccounts" resultClass="ActiveAccount">
+ select
+ Account_Id,
+ Account_FirstName,
+ Account_LastName,
+ Account_Email,
+ Account_Banner_Option,
+ Account_Cart_Option
+ from Accounts
+ order by Account_Id
+ </select>
+
+</sqlMap> \ No newline at end of file
diff --git a/tests/unit/Data/SqlMap/maps/MySql/Category.xml b/tests/unit/Data/SqlMap/maps/MySql/Category.xml
new file mode 100644
index 00000000..05c51fb5
--- /dev/null
+++ b/tests/unit/Data/SqlMap/maps/MySql/Category.xml
@@ -0,0 +1,162 @@
+<?xml version="1.0" encoding="utf-8"?>
+<sqlMap namespace="Category" >
+
+ <alias>
+ <typeAlias alias="Category" type="IBatisNet.DataMapper.Test.Domain.Category, IBatisNet.DataMapper.Test"/>
+ </alias>
+
+
+ <select id="GetCategory" parameterClass="Integer" resultClass="Category">
+ select
+ Category_ID as Id,
+ Category_Name as Name,
+ Category_Guid as GuidString
+ from Categories
+ where Category_ID = #value#
+ </select>
+
+ <select id="GetCategoryGuid" parameterClass="Integer" resultClass="guid">
+ select
+ Category_Guid as value
+ from Categories
+ where Category_ID = #value#
+ </select>
+
+ <!-- Test for statement as insert -->
+ <!-- Needs to be <insert> vs <statement> for MySql due to selectKey -->
+ <insert id="InsertCategory" parameterClass="Category">
+ <selectKey property="Id" type="post" resultClass="int">
+ select LAST_INSERT_ID() as value
+ </selectKey>
+ insert into Categories
+ (Category_Name, Category_Guid)
+ values
+ (#Name#, #GuidString:Varchar#);
+ </insert>
+
+ <!-- -->
+ <insert id="InsertCategoryViaInsertStatement" parameterClass="Category" >
+ <selectKey property="Id" type="post" resultClass="int">
+ select LAST_INSERT_ID() as value
+ </selectKey>
+ insert into Categories
+ (Category_Name, Category_Guid)
+ values
+ (#Name#, #GuidString:Varchar#)
+ </insert>
+
+ <!-- Needs to be <insert> vs <statement> for MySql due to selectKey -->
+ <insert id="InsertCategoryViaParameterMap" parameterMap="InsertParam">
+ <selectKey property="Id" type="post" resultClass="int">
+ select LAST_INSERT_ID() as value
+ </selectKey>
+ insert into Categories
+ (Category_Name, Category_Guid)
+ values
+ (?,?);
+ </insert>
+
+ <!-- Needs to be <insert> vs <statement> for MySql due to selectKey -->
+ <insert id="InsertCategoryNull" parameterMap="insert-null-params">
+ <selectKey property="Id" type="post" resultClass="int">
+ select LAST_INSERT_ID() as value
+ </selectKey>
+ insert into Categories
+ (Category_Name, Category_Guid)
+ values
+ (?,?);
+ </insert>
+
+ <update id="UpdateCategoryViaParameterMap" parameterMap="UpdateParam">
+ update Categories set
+ Category_Name =?,
+ Category_Guid = ?
+ where
+ Category_Id = ?
+ </update>
+
+ <procedure id="InsertCategoryViaStoreProcedure" parameterMap="category-insert-params">
+ ps_InsertCategorie
+ </procedure>
+
+ <insert id="InsertCategoryGenerate" parameterMap="insert-generate-params">
+ <selectKey property="Id" type="post" resultClass="int">
+ select LAST_INSERT_ID() as value
+ </selectKey>
+ <generate table="Categories" />
+ </insert>
+
+ <update id="UpdateCategoryGenerate" parameterMap="update-generate-params">
+ <generate table="Categories" by="Category_Id"/>
+ </update>
+
+ <delete id="DeleteCategoryGenerate" parameterMap="delete-generate-params">
+ <generate table="Categories" by="Category_Id, Category_Name"/>
+ </delete>
+
+ <select id="SelectByPKCategoryGenerate" resultClass="Category" parameterClass="Category" parameterMap="select-generate-params">
+ <generate table="Categories" by="Category_Id"/>
+ </select>
+
+ <select id="SelectAllCategoryGenerate" resultClass="Category" parameterMap="select-generate-params">
+ <generate table="Categories" />
+ </select>
+
+ <statement id="DynamicGuid"
+ resultClass="Category"
+ parameterClass="Category">
+ select
+ Category_ID as Id,
+ Category_Name as Name,
+ Category_Guid as Guid
+ from Categories
+ <dynamic prepend="where">
+ <isNotEqual prepend="and" property="Guid" compareProperty="EmptyGuid">
+ Category_Guid=#GuidString:Varchar#
+ </isNotEqual>
+ </dynamic>
+ </statement>
+ <parameterMap id="category-insert-params">
+ <parameter property="Id" column="Category_Id" dbType="Int32" />
+ <parameter property="Name" column="Category_Name"/>
+ <parameter property="GuidString" column="Category_Guid" dbType="Varchar"/>
+ </parameterMap>
+
+ <parameterMap id="InsertParam">
+ <parameter property="Name" column="Category_Name"/>
+ <parameter property="GuidString" column="Category_Guid" dbType="Varchar"/>
+ </parameterMap>
+
+ <parameterMap id="insert-null-params">
+ <parameter property="Name" column="Category_Name"/>
+ <parameter property="GuidString" column="Category_Guid" nullValue="00000000-0000-0000-0000-000000000000" dbType="Varchar"/>
+ </parameterMap>
+
+ <parameterMap id="UpdateParam" extends="InsertParam">
+ <parameter property="Id" column="Category_Id" />
+ </parameterMap>
+
+ <!-- Used by generated statement -->
+
+ <parameterMap id="insert-generate-params">
+ <parameter property="Name" column="Category_Name"/>
+ <parameter property="GuidString" column="Category_Guid" dbType="Varchar"/>
+ </parameterMap>
+
+ <parameterMap id="update-generate-params" extends="insert-generate-params">
+ <parameter property="Id" column="Category_Id" />
+ </parameterMap>
+
+ <parameterMap id="delete-generate-params">
+ <parameter property="Id" column="Category_Id" />
+ <parameter property="Name" column="Category_Name"/>
+ </parameterMap>
+
+ <parameterMap id="select-generate-params">
+ <parameter property="Id" column="Category_Id" />
+ <parameter property="Name" column="Category_Name"/>
+ <parameter property="GuidString" column="Category_Guid" dbType="Varchar"/>
+ </parameterMap>
+
+
+</sqlMap>
diff --git a/tests/unit/Data/SqlMap/maps/MySql/Complex.xml b/tests/unit/Data/SqlMap/maps/MySql/Complex.xml
new file mode 100644
index 00000000..c596e555
--- /dev/null
+++ b/tests/unit/Data/SqlMap/maps/MySql/Complex.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<sqlMap namespace="Complex" >
+
+ <statements>
+
+ <statement id="ComplexMap"
+ resultClass="int" >
+ select Account_ID from Accounts where Account_ID = #obj.Map.Id#
+ </statement>
+
+ <insert id="InsertComplexAccountViaInlineDefaultNull"
+ parameterClass="Hashtable" >
+ insert into Accounts
+ (Account_ID, Account_FirstName, Account_LastName, Account_Email)
+ values
+ (#obj.Map.acct.Id#, #obj.Map.acct.FirstName#, #obj.Map.acct.LastName#, #obj.Map.acct.EmailAddress:Varchar:no_email@provided.com#
+ )
+ </insert>
+
+ </statements>
+
+
+</sqlMap>
diff --git a/tests/unit/Data/SqlMap/maps/MySql/Document.xml b/tests/unit/Data/SqlMap/maps/MySql/Document.xml
new file mode 100644
index 00000000..805ad9d4
--- /dev/null
+++ b/tests/unit/Data/SqlMap/maps/MySql/Document.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<sqlMap namespace="Document" >
+ <resultMap id="document" class="Document">
+ <result property="Id" column="Document_Id"/>
+ <result property="Title" column="Document_Title"/>
+ <discriminator column="Document_Type" type="string"/>
+ <subMap value="Book" resultMapping="book" />
+ <subMap value="Newspaper" resultMapping="newspaper" />
+ </resultMap>
+
+ <resultMap id="document-custom-handler" class="Document">
+ <result property="Id" column="Document_Id"/>
+ <result property="Title" column="Document_Title"/>
+ <discriminator column="Document_Type" typeHandler="CustomInheritance"/>
+ <subMap value="Book" resultMapping="book" />
+ <subMap value="Newspaper" resultMapping="newspaper" />
+ </resultMap>
+
+ <resultMap id="book" class="Book" extends="document">
+ <result property="PageNumber" column="Document_PageNumber"/>
+ </resultMap>
+
+ <resultMap id="newspaper" class="Newspaper" extends="document">
+ <result property="City" column="Document_City"/>
+ </resultMap>
+
+
+ <statement id="GetAllDocument"
+ resultMap="document">
+ select
+ *
+ from Documents
+ order by Document_Type, Document_Id
+ </statement>
+
+ <select id="GetTypedCollection"
+ listClass="DocumentCollection"
+ resultMap="document">
+ select
+ *
+ from Documents
+ order by Document_Type, Document_Id
+ </select>
+
+ <select id="GetAllDocumentWithCustomTypeHandler"
+ resultMap="document-custom-handler">
+ select
+ *
+ from Documents
+ order by Document_Type, Document_Id
+ </select>
+
+</sqlMap> \ No newline at end of file
diff --git a/tests/unit/Data/SqlMap/maps/MySql/DynamicAccount.xml b/tests/unit/Data/SqlMap/maps/MySql/DynamicAccount.xml
new file mode 100644
index 00000000..5696ac65
--- /dev/null
+++ b/tests/unit/Data/SqlMap/maps/MySql/DynamicAccount.xml
@@ -0,0 +1,449 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<sqlMap namespace="Account" >
+
+ <alias>
+ <typeAlias alias="Search" type="IBatisNet.DataMapper.Test.Domain.Search, IBatisNet.DataMapper.Test"/>
+ </alias>
+
+ <statements>
+
+ <select id="DynamicAll"
+ parameterClass="Account"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ </select>
+
+ <select id="DynamicWithExtend"
+ extends="DynamicAll"
+ parameterClass="Account"
+ resultClass="Account">
+ <dynamic prepend="WHERE" >
+ <isGreaterThan prepend="AND" property="Id" compareValue="0" >
+ Account_ID = #Id#
+ </isGreaterThan>
+ <isNotNull prepend="AND" property="Ids" >
+ Account_ID in
+ <iterate property="Ids" open="(" close=")" conjunction="," >
+ #Ids[]#
+ </iterate>
+ </isNotNull>
+ <isNotEmpty prepend="AND" property="FirstName" >
+ Account_FirstName = #FirstName#
+ </isNotEmpty>
+ <isNotEmpty prepend="AND" property="LastName" >
+ Account_LastName = #LastName#
+ </isNotEmpty>
+ <isNotEmpty prepend="AND" property="EmailAddress" >
+ <isEqual property="EmailAddress" compareValue="Joe">
+ Account_Email = 'clinton.begin@ibatis.com'
+ </isEqual>
+ <isNotEqual property="EmailAddress" compareValue="Joe">
+ Account_Email = #EmailAddress#
+ </isNotEqual>
+ </isNotEmpty>
+ </dynamic>
+ </select>
+
+ <!-- IBATISNET-114: remapResults
+ <statement id="DynamicSqlOnColumnSelection"
+ parameterClass="Account"
+ resultClass="Account"
+ remapResults="true">
+ SELECT
+ Account_ID as Id,
+ <dynamic>
+ <isEqual property="LastName" compareValue="Dalton" >
+ Account_FirstName as FirstName,
+ </isEqual>
+ <isEqual property="LastName" compareValue="Dalton" >
+ Account_LastName as LastName,
+ </isEqual>
+ </dynamic>
+
+ Account_Email as EmailAddress
+ FROM
+ Accounts
+ </statement>
+ -->
+
+ <statement id="DynamicIsEqual"
+ parameterClass="string"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ <isEqual compareValue="Joe" >
+ where Account_FirstName = 'Joe'
+ </isEqual>
+ </statement>
+
+ <statement id="DynamicIsParameterPresent"
+ parameterClass="integer"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ <isParameterPresent >
+ where Account_ID = #value#
+ </isParameterPresent>
+ </statement>
+
+ <statement id="DynamicIsNotEmpty"
+ parameterClass="string"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ <isNotEmpty>
+ where Account_FirstName = #value#
+ </isNotEmpty>
+ </statement>
+
+ <statement id="DynamicIsGreater"
+ parameterClass="int"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ <isGreaterThan compareValue="3" >
+ where Account_ID = 1
+ </isGreaterThan>
+ </statement>
+
+ <statement id="DynamicIsGreaterEqual"
+ parameterClass="int"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ <isGreaterEqual compareValue="3" >
+ where Account_ID = 1
+ </isGreaterEqual>
+ </statement>
+
+ <statement id="DynamicIsLess"
+ parameterClass="int"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ <isLessThan compareValue="3" >
+ where Account_ID = 1
+ </isLessThan>
+ </statement>
+
+ <statement id="DynamicIsLessEqual"
+ parameterClass="int"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ <isLessEqual compareValue="3" >
+ where Account_ID = 1
+ </isLessEqual>
+ </statement>
+
+ <statement id="DynamicIsNotNull"
+ parameterClass="string"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ <isNotNull>
+ where Account_ID = 1
+ </isNotNull>
+ </statement>
+
+ <statement id="DynamicIsPropertyAvailable"
+ parameterClass="string"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ <isPropertyAvailable property="Id" >
+ where Account_ID = 1
+ </isPropertyAvailable>
+ </statement>
+
+
+ <statement id="DynamicSubst"
+ parameterClass="map"
+ resultClass="Account">
+ <dynamic>
+ $statement$
+ </dynamic>
+ </statement>
+
+ <statement id="DynamicIterate"
+ parameterClass="list"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ WHERE Account_ID IN
+ <iterate open="(" close=")" conjunction=",">
+ #[]#
+ </iterate>
+ </statement>
+
+ <statement id="DynamicIterate2"
+ parameterClass="Account"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ WHERE Account_ID IN
+ <iterate property="Ids" open="(" close=")" conjunction="," >
+ #Ids[]#
+ </iterate>
+ </statement>
+
+ <statement id="MultiDynamicIterate"
+ parameterClass="list"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ WHERE Account_ID IN
+ <iterate open="(" close=")" conjunction=",">
+ #[]#
+ </iterate>
+ and Account_ID IN
+ <iterate open="(" close=")" conjunction=",">
+ #[]#
+ </iterate>
+ </statement>
+
+
+ <statement id="DynamicQueryByExample"
+ parameterClass="Account"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ <dynamic prepend="WHERE" >
+ <isGreaterThan prepend="AND" property="Id" compareValue="0" >
+ Account_ID = #Id#
+ </isGreaterThan>
+ <isNotNull prepend="AND" property="Ids" >
+ Account_ID in
+ <iterate property="Ids" open="(" close=")" conjunction="," >
+ #Ids[]#
+ </iterate>
+ </isNotNull>
+ <isNotEmpty prepend="AND" property="FirstName" >
+ Account_FirstName = #FirstName#
+ </isNotEmpty>
+ <isNotEmpty prepend="AND" property="LastName" >
+ Account_LastName = #LastName#
+ </isNotEmpty>
+ <isNotEmpty prepend="AND" property="EmailAddress" >
+ <isEqual property="EmailAddress" compareValue="Joe">
+ Account_Email = 'clinton.begin@ibatis.com'
+ </isEqual>
+ <isNotEqual property="EmailAddress" compareValue="Joe">
+ Account_Email = #EmailAddress#
+ </isNotEqual>
+ </isNotEmpty>
+ </dynamic>
+ </statement>
+
+ <statement id="DynamicIterateWithPrepend1"
+ parameterClass="list"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ <dynamic prepend="where" >
+ Account_ID IN
+ <iterate open="(" close=")" conjunction=",">
+ #[]#
+ </iterate>
+ </dynamic>
+ </statement>
+
+ <statement id="DynamicIterateWithPrepend2"
+ parameterClass="list"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ <dynamic prepend="where" >
+ <iterate open="(" close=")" conjunction="OR">
+ Account_ID = #[]#
+ </iterate>
+ </dynamic>
+ </statement>
+
+ <statement id="DynamicIterateWithPrepend3"
+ parameterClass="list"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ <dynamic prepend="where" >
+ <isParameterPresent prepend="BLAH!" >
+ <iterate open="(" close=")" conjunction="OR">
+ Account_ID = #[]#
+ </iterate>
+ </isParameterPresent>
+ </dynamic>
+ </statement>
+
+ <statement id="DynamicWithPrepend"
+ parameterClass="Account"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ <dynamic prepend="where">
+ <isParameterPresent>
+ <isNotEmpty prepend="and" property="Id" >
+ Account_ID = #Id#
+ </isNotEmpty>
+ <isNotEmpty prepend="and" property="FirstName" >
+ Account_FirstName = #FirstName#
+ </isNotEmpty>
+ <isNotEmpty prepend="and" property="LastName" >
+ Account_LastName = #LastName#
+ </isNotEmpty>
+ </isParameterPresent>
+ </dynamic>
+ </statement>
+
+ <statement id="DynamicWithTwoDynamicElements"
+ parameterClass="Account"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ <dynamic prepend="where">
+ <isNotEmpty prepend="BLAH!" property="Id" >
+ Account_ID = #Id#
+ </isNotEmpty>
+ </dynamic>
+ <dynamic prepend="and">
+ <isNotEmpty prepend="BLAH!" property="FirstName" >
+ Account_FirstName = #FirstName#
+ </isNotEmpty>
+ <isNotEmpty prepend="and" property="LastName" >
+ Account_LastName = #LastName#
+ </isNotEmpty>
+ </dynamic>
+ </statement>
+
+ <statement id="ComplexDynamicStatement"
+ cacheModel="account-cache"
+ resultClass="Account"
+ parameterClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ <dynamic prepend="WHERE">
+ <isNotNull prepend="AND" property="FirstName">
+ (Account_FirstName = #FirstName#
+ <isNotNull prepend="OR" property="LastName">
+ Account_LastName = #LastName#
+ </isNotNull>
+ )
+ </isNotNull>
+ <isNotNull prepend="AND" property="EmailAddress">
+ Account_Email like #EmailAddress#
+ </isNotNull>
+ <isGreaterThan prepend="AND" property="Id" compareValue="0">
+ Account_ID = #Id#
+ </isGreaterThan>
+ </dynamic>
+ order by Account_LastName
+ </statement>
+
+ <statement id="Jira-IBATISNET-11"
+ resultClass="Account"
+ parameterClass="Search">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ <dynamic prepend="where">
+ <isNotNull prepend="and" property="NumberSearch">
+ ((Account_ID $Operande$ #NumberSearch#) or
+ (Account_ID $Operande$ #NumberSearch#))
+ </isNotNull>
+ <isEqual prepend="and" property="StartDate" compareValue="25/12/2004">
+ <![CDATA[Account_FirstName >= #StartDate# ]]>
+ </isEqual>
+ <isEqual prepend="and" property="StartDateAnd" compareValue="true">
+ <![CDATA[Account_LastName >= #StartDate# ]]>
+ </isEqual>
+ </dynamic>
+
+ order by Account_LastName
+ </statement>
+ </statements>
+
+
+</sqlMap> \ No newline at end of file
diff --git a/tests/unit/Data/SqlMap/maps/MySql/Enumeration.xml b/tests/unit/Data/SqlMap/maps/MySql/Enumeration.xml
new file mode 100644
index 00000000..930f2e5e
--- /dev/null
+++ b/tests/unit/Data/SqlMap/maps/MySql/Enumeration.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="utf-8"?>
+<sqlMap namespace="Enumeration" >
+
+ <alias>
+ <typeAlias alias="Enumeration" type="IBatisNet.DataMapper.Test.Domain.Enumeration, IBatisNet.DataMapper.Test"/>
+ </alias>
+
+ <resultMaps>
+ <resultMap id="enumeration-result" class="Enumeration" >
+ <result property="Id" column="Enum_ID"/>
+ <result property="Day" column="Enum_Day"/>
+ <result property="Color" column="Enum_Color"/>
+ <result property="Month" column="Enum_Month" nullValue="All"/>
+ </resultMap>
+ </resultMaps>
+
+ <statements>
+
+ <select id="GetEnumerationNullValue"
+ parameterClass="Integer"
+ resultMap="enumeration-result">
+ select
+ Enum_ID,
+ Enum_Day,
+ Enum_Color,
+ Enum_Month
+ from Enumerations
+ where Enum_ID = #value#
+ </select>
+
+ <select id="GetEnumeration" parameterClass="Integer" resultClass="Enumeration">
+ select
+ Enum_ID as Id,
+ Enum_Day as Day,
+ Enum_Color as Color,
+ Enum_Month as Month
+ from Enumerations
+ where Enum_ID = #value#
+ </select>
+
+ <insert id="InsertEnumViaParameterMap" parameterMap="insert-params" >
+ insert into Enumerations
+ (Enum_ID, Enum_Day, Enum_Color, Enum_Month)
+ values
+ (?, ?, ?, ?)
+ </insert>
+
+ </statements>
+
+ <parameterMaps>
+ <parameterMap id="insert-params">
+ <parameter property="Id" column="Enum_ID" />
+ <parameter property="Day" column="Enum_Day"/>
+ <parameter property="Color" column="Enum_Color" />
+ <parameter property="Month" column="Enum_Month" nullValue="All"/>
+ </parameterMap>
+ </parameterMaps>
+
+</sqlMap>
diff --git a/tests/unit/Data/SqlMap/maps/MySql/LineItem.xml b/tests/unit/Data/SqlMap/maps/MySql/LineItem.xml
new file mode 100644
index 00000000..c29524c2
--- /dev/null
+++ b/tests/unit/Data/SqlMap/maps/MySql/LineItem.xml
@@ -0,0 +1,188 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<sqlMap namespace="LineItem" >
+
+ <alias>
+ <typeAlias alias="LineItem" type="IBatisNet.DataMapper.Test.Domain.LineItem, IBatisNet.DataMapper.Test" />
+ <typeAlias alias="LineItemCollection" type="IBatisNet.DataMapper.Test.Domain.LineItemCollection, IBatisNet.DataMapper.Test" />
+ </alias>
+
+ <resultMap id="LineItem-Price" class="float">
+ <result property="value" column="LineItem_Price"/>
+ </resultMap>
+
+ <resultMap id="LineItem" class="LineItem">
+ <result property="Id" column="LineItem_Id"/>
+ <result property="Code" column="LineItem_Code"/>
+ <result property="Quantity" column="LineItem_Quantity"/>
+ <result property="Price" column="LineItem_Price"/>
+ </resultMap>
+
+ <resultMap id="LineItemWithNullReplacement" class="LineItem">
+ <result property="Id" column="LineItem_Id"/>
+ <result property="Code" column="LineItem_Code"/>
+ <result property="Quantity" column="LineItem_Quantity"/>
+ <result property="Price" column="LineItem_Price" nullValue="-77.77"/>
+ </resultMap>
+
+
+ <statement id="GetLineItemPrice"
+ parameterClass="array"
+ resultMap="LineItem-Price" >
+ select
+ LineItem_Price
+ from LineItems
+ where Order_ID = #Order_ID#
+ and LineItem_ID = #LineItem_ID#
+ </statement>
+
+ <statement id="GetLineItemsForOrder"
+ parameterClass="int"
+ listClass="TList"
+ resultClass="LineItem">
+ select
+ LineItem_ID as Id,
+ LineItem_Code as Code,
+ LineItem_Quantity as Quantity,
+ LineItem_Price as Price
+ from LineItems where Order_ID = #value#
+ </statement>
+
+
+ <statement id="GetLineItemsForOrderWithListClass"
+ parameterClass="int"
+ listClass="LineItemCollection"
+ resultClass="LineItem">
+ select
+ LineItem_ID as Id,
+ LineItem_Code as Code,
+ LineItem_Quantity as Quantity,
+ LineItem_Price as Price
+ from LineItems where Order_ID = #value#
+ order by LineItem_Code
+ </statement>
+
+ <statement id="GetSpecificLineItem"
+ parameterClass="array"
+ resultClass="LineItem">
+ select
+ LineItem_ID as Id,
+ LineItem_Code as Code,
+ LineItem_Quantity as Quantity,
+ LineItem_Price as Price
+ from LineItems
+ where Order_ID = #Order_ID#
+ and LineItem_ID = #LineItem_ID#
+ </statement>
+
+ <statement id="GetSpecificLineItemWithPicture"
+ parameterClass="array"
+ resultClass="LineItem">
+ select
+ LineItem_ID as Id,
+ LineItem_Code as Code,
+ LineItem_Quantity as Quantity,
+ LineItem_Price as Price,
+ LineItem_Picture as PictureData
+ from LineItems
+ where Order_ID = #Order_ID#
+ and LineItem_ID = #LineItem_ID#
+ </statement>
+
+ <select id="GetDynSpecificLineItem"
+ parameterClass="array"
+ resultClass="LineItem">
+ select
+ LineItem_ID as Id,
+ LineItem_Code as Code,
+ LineItem_Quantity as Quantity,
+ LineItem_Price as Price
+ from LineItems
+ where Order_ID = #Order_ID#
+ <dynamic>
+ <isNotNull property="LineItem_ID">
+ and LineItem_ID = #LineItem_ID#
+ </isNotNull>
+ </dynamic>
+ </select>
+
+ <statement id="GetSpecificLineItemWithNullReplacement"
+ parameterClass="int"
+ resultMap="LineItemWithNullReplacement">
+ select
+ LineItem_ID,
+ LineItem_Code,
+ LineItem_Quantity,
+ LineItem_Price
+ from LineItems
+ where LineItem_ID = #value#
+ </statement>
+
+ <statement id="InsertLineItem"
+ parameterMap="line-item-insert-params" >
+ insert into LineItems
+ (LineItem_ID, Order_ID, LineItem_Code, LineItem_Quantity, LineItem_Price)
+ values
+ (?, ?, ?, ?, ?);
+ </statement>
+
+ <statement id="InsertLineItemWithPicture"
+ parameterMap="line-item-insert-params-picture" >
+ insert into LineItems
+ (LineItem_ID, Order_ID, LineItem_Code, LineItem_Quantity, LineItem_Price, LineItem_Picture)
+ values
+ (?, ?, ?, ?, ?, ?);
+ </statement>
+
+ <insert id="InsertLineItemPostKey" parameterClass="LineItem">
+ insert into LineItems
+ (LineItem_ID, Order_ID, LineItem_Code, LineItem_Quantity, LineItem_Price)
+ values
+ (#Id#, #Order.Id#, #Code#, #Quantity#, #Price, type=float#)
+ <selectKey property="Id" type="post" resultClass="int" >
+ select 99 from LineItems where LineItem_ID = 1 and Order_ID=1
+ </selectKey>
+ </insert>
+
+ <insert id="InsertLineItemPreKey" parameterClass="LineItem">
+ <selectKey property="Id" type="pre" resultClass="int" >
+ select 99 from LineItems where LineItem_ID = 1 and Order_ID=1
+ </selectKey>
+ insert into LineItems
+ (LineItem_ID, Order_ID, LineItem_Code, LineItem_Quantity, LineItem_Price)
+ values
+ (#Id#, #Order.Id#, #Code#, #Quantity#, #Price, type=float#)
+ </insert>
+
+ <insert id="InsertLineItemNoKey" parameterClass="LineItem">
+ insert into LineItems
+ (LineItem_ID, Order_ID, LineItem_Code, LineItem_Quantity, LineItem_Price)
+ values
+ (#Id#, #Order.Id#, #Code#, #Quantity#, #Price, type=float#)
+ </insert>
+
+ <!-- JIRA 23 -->
+ <delete id="DeleteWithComments" >
+ <!-- Delete LineItems -->
+ delete from LineItems where Order_ID = 10;
+ <!-- Delete LineItems -->
+ </delete>
+
+ <parameterMap id="line-item-insert-params">
+ <parameter property="Id" />
+ <parameter property="Order.Id" />
+ <parameter property="Code" />
+ <parameter property="Quantity" />
+ <parameter property="Price" dbType="Decimal" nullValue="-99.99"/>
+ </parameterMap>
+
+ <parameterMap id="line-item-insert-params-picture">
+ <parameter property="Id" />
+ <parameter property="Order.Id" />
+ <parameter property="Code" />
+ <parameter property="Quantity" />
+ <parameter property="Price" dbType="Decimal" nullValue="-99.99"/>
+ <parameter property="PictureData" dbType="Blob" />
+ </parameterMap>
+
+</sqlMap> \ No newline at end of file
diff --git a/tests/unit/Data/SqlMap/maps/MySql/Order.xml b/tests/unit/Data/SqlMap/maps/MySql/Order.xml
new file mode 100644
index 00000000..a62df9e1
--- /dev/null
+++ b/tests/unit/Data/SqlMap/maps/MySql/Order.xml
@@ -0,0 +1,468 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<sqlMap namespace="Order">
+
+ <alias>
+ <typeAlias alias="Order" type="IBatisNet.DataMapper.Test.Domain.Order, IBatisNet.DataMapper.Test" />
+ </alias>
+
+ <!-- If the type is not specified, ADO.NET infers the
+ data provider Type of the Parameter from the Value property
+ of the Parameter object. -->
+
+
+ <resultMap id="credit-card-result" class="string">
+ <result property="value" column="Order_CardNumber"/>
+ </resultMap>
+ <!-- -->
+ <resultMap id="order-with-lines-result" class="Order"
+ extends="lite-order-result-by-name" >
+ <result property="LineItemsList" lazyLoad="true" type="TList" column="Order_Id" select="GetLineItemsForOrder" />
+ </resultMap>
+
+ <resultMap id="order-with-lines-result-no-lazy-load" class="Order"
+ extends="lite-order-result-by-name" >
+ <result property="LineItemsList" type="TList" column="Order_Id" select="GetLineItemsForOrder" />
+ </resultMap>
+
+ <resultMap id="order-with-lines-result-statement-namespaces" class="Order"
+ extends="lite-order-result-by-name" >
+ <result property="LineItemsList" lazyLoad="true" type="TList" column="Order_Id" select="LineItem.GetLineItemsForOrder" />
+ </resultMap>
+
+ <resultMap id="order-with-lines-collection" class="Order"
+ extends="lite-order-result-by-name" >
+ <result property="LineItems" column="Order_Id" lazyLoad="true"
+ select="GetLineItemsForOrderWithListClass" />
+ </resultMap>
+
+ <resultMap id="order-with-lines-collection-no-lazy-load" class="Order"
+ extends="lite-order-result-by-name" >
+ <result property="LineItems" column="Order_Id"
+ select="GetLineItemsForOrderWithListClass" />
+ </resultMap>
+
+ <resultMap id="order-with-lines-array" class="Order"
+ extends="lite-order-result-by-name">
+ <result property="LineItemsArray" column="Order_Id" select="GetLineItemsForOrder"/>
+ </resultMap>
+
+ <resultMap id="lite-order-map-result" class="array">
+ <result property="Id" type="Int" column="Order_Id"/>
+ <result property="Date" type="date" column="Order_Date"/>
+ <result property="CardExpiry" type="string" column="Order_CardExpiry"/>
+ <result property="CardType" type="string" column="Order_CardType"/>
+ <result property="CardNumber" type="string" column="Order_CardNumber"/>
+ <result property="Street" type="string" column="Order_Street"/>
+ <result property="City" type="string" column="Order_City"/>
+ <result property="Province" type="string" column="Order_Province"/>
+ <result property="PostalCode" type="string" column="Order_PostalCode"/>
+ </resultMap>
+
+ <resultMap id="lite-order-result-by-name" class="Order">
+ <result property="Id" column="Order_Id"/>
+ <result property="Date" type="date" column="Order_Date" nullValue="0001-01-01 00:00:00"/>
+ <result property="CardExpiry" column="Order_CardExpiry"/>
+ <result property="CardType" column="Order_CardType"/>
+ <result property="CardNumber" column="Order_CardNumber"/>
+ <result property="Street" column="Order_Street"/>
+ <result property="City" column="Order_City"/>
+ <result property="Province" column="Order_Province"/>
+ <result property="PostalCode" column="Order_PostalCode"/>
+ </resultMap>
+
+ <resultMap id="order-hash" class="array">
+ <result property="Date" column="Order_Date" nullValue="0001-01-01 00:00:00"/>
+ </resultMap>
+
+ <resultMap id="order-with-types-result" class="Order">
+ <result property="Id" column="Order_Id" />
+ <result property="Date" column="Order_Date" type="date" />
+ <result property="CardExpiry" column="Order_CardExpiry" />
+ <result property="CardType" column="Order_CardType" />
+ <result property="CardNumber" column="Order_CardNumber" />
+ <result property="Street" column="Order_Street" />
+ <result property="City" column="Order_City" />
+ <result property="Province" column="Order_Province" />
+ <result property="PostalCode" column="Order_PostalCode" />
+ </resultMap>
+
+ <resultMap id="lite-order-result-by-index" class="Order">
+ <result property="Id" column="Order_Id" columnIndex="0"/>
+ <result property="Date" column="Order_Date" type="date" columnIndex="1" />
+ <result property="CardExpiry" column="Order_CardExpiry" columnIndex="2"/>
+ <result property="CardType" column="Order_CardType" columnIndex="3" />
+ <result property="CardNumber" column="Order_CardNumber" columnIndex="4" />
+ <result property="Street" column="Order_Street" columnIndex="5" />
+ <result property="City" column="Order_City" columnIndex="6" />
+ <result property="Province" column="Order_Province" columnIndex="7"/>
+ <result property="PostalCode" column="Order_PostalCode" columnIndex="8" />
+ </resultMap>
+
+ <resultMap id="order-with-account-result" class="Order">
+ <result property="Id" column="Order_Id"/>
+ <result property="Date" type="date" column="Order_Date"/>
+ <result property="CardExpiry" column="Order_CardExpiry"/>
+ <result property="CardType" column="Order_CardType"/>
+ <result property="CardNumber" column="Order_CardNumber"/>
+ <result property="Street" column="Order_Street"/>
+ <result property="City" column="Order_City"/>
+ <result property="Province" column="Order_Province"/>
+ <result property="PostalCode" column="Order_PostalCode"/>
+ <result property="Account" column="Account_Id" select="GetAccountViaColumnName" />
+ </resultMap>
+
+ <resultMap id="order-with-collection-result" class="Order">
+ <result property="Id" column="Order_Id"/>
+ <result property="Date" type="date" column="Order_Date"/>
+ <result property="CardExpiry" column="Order_CardExpiry"/>
+ <result property="CardType" column="Order_CardType"/>
+ <result property="CardNumber" column="Order_CardNumber"/>
+ <result property="Street" column="Order_Street"/>
+ <result property="City" column="Order_City"/>
+ <result property="Province" column="Order_Province"/>
+ <result property="PostalCode" column="Order_PostalCode"/>
+ <result property="LineItemsList" column="Order_Id" select="GetLineItemsForOrder" />
+ <result property="LineItems" column="Order_Id" select="GetLineItemsForOrder" lazyLoad="false" />
+ </resultMap>
+
+ <resultMap id="order-with-favourite-line-item" class="Order">
+ <result property="Id" column="Order_Id"/>
+ <result property="Date" column="Order_Date"/>
+ <result property="CardExpiry" column="Order_CardExpiry"/>
+ <result property="CardType" column="Order_CardType"/>
+ <result property="CardNumber" column="Order_CardNumber"/>
+ <result property="Street" column="Order_Street"/>
+ <result property="City" column="Order_City"/>
+ <result property="Province" column="Order_Province"/>
+ <result property="PostalCode" column="Order_PostalCode"/>
+ <result property="FavouriteLineItem"
+ column="Order_ID=Order_Id,LineItem_ID=Order_FavouriteLineItem"
+ select="GetSpecificLineItem" />
+ </resultMap>
+
+ <resultMap id="order-with-dyn-favourite-line-item" class="Order">
+ <result property="Id" column="Order_Id"/>
+ <result property="Date" column="Order_Date"/>
+ <result property="CardExpiry" column="Order_CardExpiry"/>
+ <result property="CardType" column="Order_CardType"/>
+ <result property="CardNumber" column="Order_CardNumber"/>
+ <result property="Street" column="Order_Street"/>
+ <result property="City" column="Order_City"/>
+ <result property="Province" column="Order_Province"/>
+ <result property="PostalCode" column="Order_PostalCode"/>
+ <result property="FavouriteLineItem"
+ column="Order_ID=Order_Id,LineItem_ID=Order_FavouriteLineItem"
+ select="GetDynSpecificLineItem" />
+ </resultMap>
+
+ <resultMap id="order-joined-favourite" class="Order">
+ <result property="Id" column="Order_Id"/>
+ <result property="Date" type="date" column="Order_Date"/>
+ <result property="CardExpiry" column="Order_CardExpiry"/>
+ <result property="CardType" column="Order_CardType"/>
+ <result property="CardNumber" column="Order_CardNumber"/>
+ <result property="Street" column="Order_Street"/>
+ <result property="City" column="Order_City"/>
+ <result property="Province" column="Order_Province"/>
+ <result property="PostalCode" column="Order_PostalCode"/>
+ <result property="FavouriteLineItem" resultMapping="LineItem" />
+ </resultMap>
+
+ <resultMap id="order-joined-favourite2" class="Order">
+ <result property="Id" column="Order_Id"/>
+ <result property="Date" type="date" column="Order_Date"/>
+ <result property="CardExpiry" column="Order_CardExpiry"/>
+ <result property="CardType" column="Order_CardType"/>
+ <result property="CardNumber" column="Order_CardNumber"/>
+ <result property="Street" column="Order_Street"/>
+ <result property="City" column="Order_City"/>
+ <result property="Province" column="Order_Province"/>
+ <result property="PostalCode" column="Order_PostalCode"/>
+ <result property="FavouriteLineItem.Id" column="LineItem_Id"/>
+ <result property="FavouriteLineItem.Code" column="LineItem_Code"/>
+ <result property="FavouriteLineItem.Quantity" column="LineItem_Quantity"/>
+ <result property="FavouriteLineItem.Price" column="LineItem_Price"/>
+ </resultMap>
+
+ <resultMap id="order-joined-with-account" class="Order">
+ <result property="Id" column="Order_Id"/>
+ <result property="Date" type="date" column="Order_Date" nullValue="0001-01-01 00:00:00"/>
+ <result property="CardExpiry" column="Order_CardExpiry"/>
+ <result property="CardType" column="Order_CardType"/>
+ <result property="CardNumber" column="Order_CardNumber"/>
+ <result property="Street" column="Order_Street"/>
+ <result property="City" column="Order_City"/>
+ <result property="Province" column="Order_Province"/>
+ <result property="PostalCode" column="Order_PostalCode"/>
+ <result property="Account" resultMapping="account-result-nullable-email" />
+ </resultMap>
+
+ <statement id="GetOrderLiteByColumnName"
+ parameterClass="integer"
+ resultMap="lite-order-result-by-name" >
+ select * from Orders where Order_Id = #value#
+ </statement>
+
+ <statement id="GetOrderByHashTable"
+ parameterClass="Int"
+ resultMap="order-hash" >
+ select Order_Date from Orders where Order_Id = #value#
+ </statement>
+
+ <statement id="GetOrderLiteByColumnIndex"
+ parameterClass="Int"
+ resultMap="lite-order-result-by-index" >
+ select
+ Order_Id,
+ Order_Date,
+ Order_CardExpiry,
+ Order_CardType,
+ Order_CardNumber,
+ Order_Street,
+ Order_City,
+ Order_Province,
+ Order_PostalCode
+ from Orders where Order_Id = #value#
+ </statement>
+
+ <statement id="GetOrderWithTypes"
+ parameterClass="Int"
+ resultMap="order-with-types-result" >
+ select * from Orders where Order_Id = #value#
+ </statement>
+
+ <statement id="GetOrderWithLineItems"
+ parameterClass="Integer"
+ ListClass="TList"
+ resultMap="order-with-lines-result" >
+ select * from Orders where Order_Id = #value#
+ </statement>
+
+
+ <statement id="GetOrderWithLineItemsNoLazyLoad"
+ parameterClass="Integer"
+ resultMap="order-with-lines-result-no-lazy-load" >
+ select * from Orders where Order_Id = #value#
+ </statement>
+
+ <statement id="GetOrderWithLineItemsUsingStatementNamespaces"
+ parameterClass="Integer"
+ resultMap="order-with-lines-result-statement-namespaces" >
+ select * from Orders where Order_Id = #value#
+ </statement>
+
+ <statement id="GetAllOrderWithLineItems"
+ resultMap="order-with-lines-result" >
+ select * from Orders
+ </statement>
+
+ <statement id="GetOrderCardExpiryViaResultClass"
+ parameterClass="int"
+ resultClass="date">
+ select
+ Order_Date as 'datetime'
+ from Orders where Order_Id = #value#
+ </statement>
+
+ <statement id="GetOrderWithAccount"
+ parameterClass="int"
+ resultMap="order-with-account-result" >
+ select * from Orders where Order_Id = #value#
+ </statement>
+
+ <statement id="GetOrderWithLineItemsCollection"
+ parameterClass="Integer"
+ resultMap="order-with-collection-result" >
+ select * from Orders where Order_Id = #value#
+ </statement>
+
+ <statement id="GetOrderJoinedFavourite"
+ parameterClass="Integer"
+ resultMap="order-joined-favourite" >
+ select * from Orders, LineItems
+ where Orders.Order_Id = LineItems.Order_Id
+ and Order_FavouriteLineItem = LineItems.LineItem_ID
+ and Orders.Order_Id = #value#
+ </statement>
+
+ <statement id="GetOrderJoinedFavourite2"
+ parameterClass="Integer"
+ resultMap="order-joined-favourite2" >
+ select * from Orders, LineItems
+ where Orders.Order_Id = LineItems.Order_Id
+ and Order_FavouriteLineItem = LineItems.LineItem_ID
+ and Orders.Order_Id = #value#
+ </statement>
+
+ <statement id="GetOrderJoinedFavourite3"
+ parameterClass="Integer"
+ resultClass="Order" >
+ select
+ Orders.Order_Id as Id,
+ Order_Date as Date,
+ Order_CardExpiry as CardExpiry,
+ Order_CardType as CardType,
+ Order_CardNumber as CardNumber,
+ Order_Street as Street,
+ Order_City as City,
+ Order_Province as Province,
+ Order_PostalCode as PostalCode,
+ LineItem_ID as "FavouriteLineItem.Id",
+ LineItem_Code as "FavouriteLineItem.Code",
+ LineItem_Quantity as "FavouriteLineItem.Quantity",
+ LineItem_Price as "FavouriteLineItem.Price"
+ from Orders, LineItems
+ where Orders.Order_Id = LineItems.Order_Id
+ and Order_FavouriteLineItem = LineItems.LineItem_ID
+ and Orders.Order_Id = #value#
+ </statement>
+
+ <statement id="GetOrderWithFavouriteLineItem"
+ parameterClass="int"
+ resultMap="order-with-favourite-line-item" >
+ select * from Orders where Order_Id = #value#
+ </statement>
+
+ <statement id="GetOrderWithLineItemCollection"
+ parameterClass="int"
+ resultMap="order-with-lines-collection" >
+ select * from Orders where Order_Id = #value#
+ </statement>
+
+ <statement id="GetOrderWithLineItemCollectionNoLazy"
+ parameterClass="int"
+ resultMap="order-with-lines-collection-no-lazy-load" >
+ select * from Orders where Order_Id = #value#
+ </statement>
+
+ <statement id="GetOrderAsHastable"
+ parameterClass="Integer"
+ resultMap="lite-order-map-result" >
+ select * from Orders where Order_Id = #value#
+ </statement>
+
+ <statement id="GetOrderWithLineItemArray"
+ parameterClass="int"
+ resultMap="order-with-lines-array">
+ select * from Orders where Order_Id = #value#
+ </statement>
+
+ <statement id="GetAllCreditCardNumbersFromOrders"
+ resultMap="credit-card-result" >
+ select distinct Order_CardNumber from Orders
+ order by Order_CardNumber
+ </statement>
+
+ <statement id="InsertOrderViaParameterMap"
+ parameterMap="order-insert-params-full" >
+ insert into Orders
+ (Order_Id, Account_ID, Order_Date, Order_CardExpiry, Order_CardType,
+ Order_CardNumber, Order_Street, Order_City, Order_Province, Order_PostalCode )
+ values
+ (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
+ </statement>
+
+ <statement id="InsertOrderViaExtendParameterMap"
+ parameterMap="insert-extend" >
+ insert into Orders
+ (Order_Id, Account_ID, Order_Date, Order_CardExpiry, Order_CardType,
+ Order_CardNumber, Order_Street, Order_City, Order_Province, Order_PostalCode )
+ values
+ (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
+ </statement>
+
+ <statement id="InsertOrderViaPublicFields">
+ insert into Orders
+ (Order_Id, Account_ID, Order_Date, Order_CardExpiry, Order_CardType,
+ Order_CardNumber, Order_Street, Order_City, Order_Province, Order_PostalCode )
+ values
+ (#Id#, #Account.Id#, #Date#, #CardExpiry#, #CardType#, #CardNumber#, #Street#, #City#, #Province#, #PostalCode#)
+ </statement>
+
+ <select id="GetOrderWithDynFavouriteLineItem"
+ parameterClass="Integer"
+ resultMap="order-with-dyn-favourite-line-item">
+ select * from Orders where Order_Id = #value#
+ </select>
+
+ <select id="SelectOrderByDate"
+ parameterClass="array"
+ resultMap="lite-order-result-by-name">
+ select * from Orders where Order_Date = #Foo#
+ </select>
+
+ <select id="SelectOrderByDateDynamic"
+ parameterClass="array"
+ resultMap="lite-order-result-by-name">
+ select * from Orders
+ where 1=1
+ <isNotEmpty prepend="AND" property="Foo">
+ (Order_Date = '$Foo$')
+ </isNotEmpty>
+ </select>
+
+ <select id="GetAccountJIRA45"
+ parameterClass="int"
+ resultMap="indexed-account-result">
+ select
+ Account_Id,
+ Account_FirstName,
+ Account_LastName,
+ Account_Email
+ from Accounts
+ where Account_ID = #value#
+ </select>
+
+ <select id="GetOrderJoinWithAccount"
+ parameterClass="Integer"
+ resultMap="order-joined-with-account">
+ select
+ Order_Id,
+ Order_Date,
+ Order_CardExpiry,
+ Order_CardType,
+ Order_CardNumber,
+ Order_Street,
+ Order_City,
+ Order_Province,
+ Order_PostalCode,
+ acc.Account_ID,
+ acc.Account_FirstName,
+ acc.Account_LastName,
+ acc.Account_Email
+ from Orders as ord
+ LEFT OUTER JOIN Accounts as acc on acc.Account_ID = ord.Account_ID
+ where Order_Id = #value#
+ </select>
+
+ <parameterMap id="order-insert-params-full">
+ <parameter property="Id" dbType="Int32"/>
+ <parameter property="Account.Id"/>
+ <parameter property="Date" nullValue="0001-01-01 00:00:00" />
+ <parameter property="CardExpiry" />
+ <parameter property="CardType" />
+ <parameter property="CardNumber" />
+ <parameter property="Street" />
+ <parameter property="City" />
+ <parameter property="Province" />
+ <parameter property="PostalCode" />
+ </parameterMap>
+
+ <parameterMap id="params-parent"> <!-- 1043181 support request -->
+ <parameter property="Id" dbType="Int32"/>
+ <parameter property="Account.Id"/>
+ <parameter property="Date" nullValue="0001-01-01 00:00:00" />
+ <parameter property="CardExpiry" />
+ <parameter property="CardType" />
+ <parameter property="CardNumber" />
+ <parameter property="Street" />
+ <parameter property="City" />
+ <parameter property="Province" />
+ <parameter property="PostalCode" />
+ </parameterMap>
+
+ <parameterMap id="insert-extend" extends="params-parent">
+ </parameterMap>
+
+</sqlMap> \ No newline at end of file
diff --git a/tests/unit/Data/SqlMap/maps/MySql/Other.xml b/tests/unit/Data/SqlMap/maps/MySql/Other.xml
new file mode 100644
index 00000000..67862029
--- /dev/null
+++ b/tests/unit/Data/SqlMap/maps/MySql/Other.xml
@@ -0,0 +1,170 @@
+<?xml version="1.0" encoding="utf-8"?>
+<sqlMap namespace="Other" >
+
+ <resultMap id="other-result" class="Other" >
+ <result property="Int" column="Other_Int"/>
+ <result property="Long" column="Other_Long"/>
+ <result property="Bool" column="Other_Bit"/>
+ <result property="Bool2" column="Other_String" typeHandler="OuiNonBool"/>
+ </resultMap>
+
+ <resultMap id="other-result-V1" class="Other" >
+ <result property="Int" column="Other_Int"/>
+ <result property="Long" column="Other_Long"/>
+ <result property="Bool" column="Other_Bit"/>
+ <result property="Bool2" column="Other_String" />
+ </resultMap>
+
+ <resultMap id="A-result" class="A" >
+ <result property="Id" column="A_ID"/>
+ <result property="Libelle" column="A_Libelle"/>
+ <result property="B" resultMapping="B-result"/>
+ <result property="E" resultMapping="E-result"/>
+ <result property="F" resultMapping="F-result"/>
+ </resultMap>
+
+ <resultMap id="B-result" class="B" >
+ <result property="Id" column="B_ID"/>
+ <result property="Libelle" column="B_Libelle"/>
+ <result property="C" resultMapping="C-result"/>
+ <result property="D" resultMapping="D-result"/>
+ </resultMap>
+
+ <resultMap id="C-result" class="C" >
+ <result property="Id" column="C_ID"/>
+ <result property="Libelle" column="C_Libelle"/>
+ </resultMap>
+
+ <resultMap id="D-result" class="D" >
+ <result property="Id" column="D_ID"/>
+ <result property="Libelle" column="D_Libelle"/>
+ </resultMap>
+
+ <resultMap id="E-result" class="E" >
+ <result property="Id" column="E_ID"/>
+ <result property="Libelle" column="E_Libelle"/>
+ </resultMap>
+
+ <resultMap id="F-result" class="F" >
+ <result property="Id" column="F_ID"/>
+ <result property="Libelle" column="F_Libelle"/>
+ </resultMap>
+
+ <select id="SelectComplexJoined" resultMap="A-result">
+ SELECT
+ A.Id AS A_ID,
+ A.A_Libelle AS A_Libelle,
+ B.ID AS B_ID,
+ B.B_Libelle AS B_Libelle,
+ C.ID AS C_ID,
+ C.C_Libelle AS C_Libelle,
+ D.ID AS D_ID,
+ D.D_Libelle AS D_Libelle,
+ E.ID AS E_ID,
+ E.E_Libelle AS E_Libelle,
+ F.ID AS F_ID,
+ F.F_Libelle AS F_Libelle
+ FROM A
+ LEFT OUTER JOIN B ON A.B_ID = B.ID
+ LEFT OUTER JOIN C ON B.C_ID = C.ID
+ LEFT OUTER JOIN D ON B.D_ID = D.ID
+ LEFT OUTER JOIN E ON A.E_ID = E.ID
+ LEFT OUTER JOIN F ON A.F_ID = F.ID
+ </select>
+
+
+ <statement id="DynamicSelectByIntLong"
+ parameterClass="Hashtable"
+ resultMap="other-result">
+ select
+ Other_Int,
+ Other_Long,
+ Other_Bit,
+ Other_String
+ from Others
+ <dynamic prepend="WHERE">
+ <isNotEqual prepend="AND" property="year" compareValue="0">
+ Other_Int = #year#
+ </isNotEqual>
+
+ <isNotEqual prepend="AND" property="areaid" compareValue="0">
+ Other_Long = #areaid#
+ </isNotEqual>
+ </dynamic>
+ </statement>
+
+ <statement id="DynamicSelectByBool"
+ parameterClass="Other"
+ resultMap="other-result">
+ select
+ Other_Int,
+ Other_Long,
+ Other_Bit,
+ Other_String
+ from Others
+ Where Other_Bit = #Bool#
+ </statement>
+
+ <statement id="InsertBool"
+ parameterClass="Other">
+ Insert into Others
+ ( Other_Int, Other_Long, Other_Bit, Other_String )
+ values
+ ( #Int#, #Long#, #Bool#, 'Yes')
+ </statement>
+
+ <statement id="InsertCustomTypeHandler"
+ parameterMap="other-insert-params">
+ Insert into Others
+ ( Other_Int, Other_Long, Other_Bit, Other_String )
+ values
+ ( ?, ?, ?, ?)
+ </statement>
+
+ <statement id="SelectByInt"
+ parameterClass="int"
+ resultMap="other-result">
+ select
+ Other_Int,
+ Other_Long,
+ Other_Bit,
+ Other_String
+ from Others
+ Where Other_Int = #value#
+ </statement>
+
+ <statement id="SelectByIntV1"
+ parameterClass="int"
+ resultMap="other-result-V1">
+ select
+ Other_Int,
+ Other_Long,
+ Other_Bit,
+ Other_String
+ from Others
+ Where Other_Int = #value#
+ </statement>
+
+ <statement id="InsertInlineCustomTypeHandlerV1"
+ parameterClass="Other">
+ Insert into Others
+ ( Other_Int, Other_Long, Other_Bit, Other_String )
+ values
+ ( #Int#, #Long#, #Bool#, #Bool2,type=bool,dbType=Varchar#)
+ </statement>
+
+ <statement id="InsertInlineCustomTypeHandlerV2"
+ parameterClass="Other">
+ Insert into Others
+ ( Other_Int, Other_Long, Other_Bit, Other_String )
+ values
+ ( #Int#, #Long#, #Bool#, #Bool2,typeHandler=OuiNonBool#)
+ </statement>
+
+ <parameterMap id="other-insert-params">
+ <parameter property="Int" />
+ <parameter property="Long" />
+ <parameter property="Bool" />
+ <parameter property="Bool2" typeHandler="OuiNonBool"/>
+ </parameterMap>
+</sqlMap>
diff --git a/tests/unit/Data/SqlMap/maps/MySql/ResultClass.xml b/tests/unit/Data/SqlMap/maps/MySql/ResultClass.xml
new file mode 100644
index 00000000..3f82ac5f
--- /dev/null
+++ b/tests/unit/Data/SqlMap/maps/MySql/ResultClass.xml
@@ -0,0 +1,130 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<sqlMap namespace="ResultClass" >
+
+ <statement id="GetBoolean"
+ parameterClass="Int"
+ resultClass="bool" >
+ select 1 from Orders where Order_ID = #dummy#
+ </statement>
+ <statement id="GetBooleanWithoutResultClass"
+ parameterClass="Int"
+ extends="GetBoolean">
+ </statement>
+
+ <statement id="GetByte"
+ parameterClass="Int"
+ resultClass="string" >
+ select 155 from Orders where Order_ID = #value#
+ </statement>
+ <statement id="GetByteWithoutResultClass"
+ parameterClass="Int"
+ extends="GetByte">
+ </statement>
+
+ <!--
+ NOTE: Use MySql 4.0.2 or higher for "cast"
+ -->
+ <statement id="GetChar"
+ parameterClass="Int"
+ resultClass="string" >
+ select cast('a' as char) from Orders where Order_ID = #value#
+ </statement>
+ <statement id="GetCharWithoutResultClass"
+ parameterClass="Int"
+ extends="GetChar">
+ </statement>
+
+ <statement id="GetDate"
+ parameterClass="Int"
+ resultClass="TDateTime" >
+ select '2003-02-15 8:15:00' as datetime from Orders where Order_ID = #value#
+ </statement>
+ <statement id="GetDateWithoutResultClass"
+ parameterClass="Int"
+ extends="GetDate">
+ </statement>
+
+ <statement id="GetDecimal"
+ parameterClass="Int"
+ resultClass="float" >
+ select 1.56 from Orders where Order_ID = #value#
+ </statement>
+ <statement id="GetDecimalWithoutResultClass"
+ parameterClass="Int"
+ extends="GetDecimal">
+ </statement>
+
+ <statement id="GetDouble"
+ parameterClass="Int"
+ resultClass="float" >
+ select 99.5 from Orders where Order_ID= #value#
+ </statement>
+ <statement id="GetDoubleWithoutResultClass"
+ parameterClass="Int"
+ extends="GetDouble">
+ </statement>
+
+ <!--
+ Use binary for cast for MySql
+ -->
+ <statement id="GetGuid"
+ parameterClass="Int"
+ resultClass="guid" >
+ select cast('CD5ABF17-4BBC-4C86-92F1-257735414CF4' as binary) from Orders where Order_ID = #value#
+ </statement>
+ <statement id="GetGuidWithoutResultClass" parameterClass="Int" extends="GetGuid">
+ </statement>
+
+ <statement id="GetInt16"
+ parameterClass="Int"
+ resultClass="int" >
+ select 32111 from Orders where Order_ID = #value#
+ </statement>
+ <statement id="GetInt16WithoutResultClass"
+ parameterClass="Int"
+ extends="GetInt16">
+ </statement>
+
+ <statement id="GetInt32"
+ parameterClass="Int"
+ resultClass="int" >
+ select 999999 from Orders where Order_ID = #value#
+ </statement>
+ <statement id="GetInt32WithoutResultClass"
+ parameterClass="Int"
+ extends="GetInt32">
+ </statement>
+
+ <statement id="GetInt64"
+ parameterClass="Int"
+ resultClass="double" >
+ select 9223372036854775800 from Orders where Order_ID = #value#
+ </statement>
+ <statement id="GetInt64WithoutResultClass"
+ parameterClass="Int"
+ extends="GetInt64">
+ </statement>
+
+ <statement id="GetSingle"
+ parameterClass="Int"
+ resultClass="float" >
+ select 92233.5 from Orders where Order_ID = #value#
+ </statement>
+ <statement id="GetSingleWithoutResultClass"
+ parameterClass="Int"
+ extends="GetSingle">
+ </statement>
+
+ <statement id="GetString"
+ parameterClass="Int"
+ resultClass="string" >
+ select 'VISA'
+ from Orders where Order_ID = #value#
+ </statement>
+ <statement id="GetStringWithoutResultClass"
+ parameterClass="Int"
+ extends="GetString">
+ </statement>
+
+</sqlMap> \ No newline at end of file
diff --git a/tests/unit/Data/SqlMap/maps/mssql/Account.xml b/tests/unit/Data/SqlMap/maps/mssql/Account.xml
new file mode 100644
index 00000000..8149d228
--- /dev/null
+++ b/tests/unit/Data/SqlMap/maps/mssql/Account.xml
@@ -0,0 +1,606 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<sqlMap namespace="Account">
+
+
+ <cacheModel id="account-cache" implementation="LRU" >
+ <flushInterval hours="24"/>
+ <flushOnExecute statement="UpdateAccountViaInlineParameters"/>
+ <flushOnExecute statement="UpdateAccountViaParameterMap"/>
+ <property id="CacheSize" value="50"/>
+ </cacheModel>
+
+
+ <resultMap id="account-result" class="Account" >
+ <result property="Id" column="Account_ID"/>
+ <result property="FirstName" column="Account_FirstName"/>
+ <result property="LastName" column="Account_LastName"/>
+ <result property="EmailAddress" column="Account_Email" nullValue="no_email@provided.com"/>
+ <result property="BannerOptions" column="Account_Banner_Option" dbType="Varchar" typeHandler="OuiNonBool"/>
+ <result property="CartOptions" column="Account_Cart_Option" typeHandler="HundredsBool"/>
+ </resultMap>
+ <resultMap id="indexed-account-result" class="Account">
+ <result property="Id" column="Account_ID" columnIndex="0"/>
+ <result property="FirstName" column="Account_FirstName" columnIndex="1"/>
+ <result property="LastName" column="Account_LastName" columnIndex="2"/>
+ <result property="EmailAddress" column="Account_Email" columnIndex="3" nullValue="no_email@provided.com"/>
+ </resultMap>
+ <resultMap id="account-result-nullable-email" class="Account">
+ <result property="Id" column="Account_ID"/>
+ <result property="FirstName" column="Account_FirstName"/>
+ <result property="LastName" column="Account_LastName"/>
+ <result property="EmailAddress" column="Account_Email"/>
+ </resultMap>
+
+ <resultMap id="email-result" class="string">
+ <result property="value" column="Account_Email"/>
+ </resultMap>
+
+ <resultMap id="account-hashtable-result" class="array">
+ <result property="Id" column="Account_ID"/>
+ <result property="FirstName" column="Account_FirstName"/>
+ <result property="LastName" column="Account_LastName"/>
+ <result property="EmailAddress" column="Account_Email"/>
+ </resultMap>
+
+
+<!-- =============================================
+ MAPPED STATEMENTS - w/Inline Parameters
+=============================================
+-->
+
+ <select id="GetAllAccountsAsArrayListViaResultClass" resultClass="TList">
+ select
+ Account_ID as ID,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ order by Account_ID
+ </select>
+
+ <select id="GetAccountsDynamic" resultMap="account-result" parameterClass="array" >
+ select top $MaximumAllowed$ * from Accounts
+ <dynamic prepend="where">
+ <isParameterPresent>
+ <isNotEmpty prepend="and" property="FirstName" >
+ Account_FirstName LIKE '%$FirstName$%'
+ </isNotEmpty>
+ <isNotEmpty prepend="and" property="LastName" >
+ Account_LastName LIKE '%$LastName$%'
+ </isNotEmpty>
+ <isNotEmpty prepend="and" property="EmailAddress" >
+ Account_Email LIKE '%$EmailAddress$%'
+ </isNotEmpty>
+ </isParameterPresent>
+ </dynamic>
+ order by Account_LastName
+ </select>
+
+ <select id="SelectWithProperty"
+ resultMap="account-result">
+ select *
+ from Accounts
+ where Account_FirstName = ${accountName}
+ </select>
+
+ <select id="GetCachedAccountsViaResultMap"
+ resultMap="account-result"
+ cacheModel="account-cache" >
+ select *
+ from Accounts
+ order by Account_ID
+ </select>
+
+ <select id="GetNoAccountWithCache"
+ parameterClass="Integer"
+ resultMap="account-hashtable-result"
+ cacheModel="account-cache">
+ select *
+ from Accounts
+ where Account_ID = #value#
+ </select>
+
+ <select id="GetAccountAsarray"
+ parameterClass="Integer"
+ resultMap="account-hashtable-result">
+ select *
+ from Accounts
+ where Account_ID = #value#
+ </select>
+
+ <select id="GetAllAccountsAsHashMapViaResultMap"
+ resultMap="account-hashtable-result">
+ select *
+ from Accounts
+ order by Account_ID
+ </select>
+
+ <select id="GetAccountAsarrayResultClass"
+ parameterClass="int"
+ resultClass="HashMap">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ where Account_ID = #value#
+ </select>
+
+ <select id="GetAllAccountsAsarrayViaResultClass"
+ resultClass="array">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ order by Account_ID
+ </select>
+
+ <select id="GetAccountViaColumnName"
+ parameterClass="int"
+ resultMap="account-result">
+ select
+ Account_ID,
+ Account_FirstName,
+ Account_LastName,
+ Account_Email,
+ Account_Banner_Option,
+ Account_Cart_Option
+ from Accounts
+ where Account_ID = #value#
+ </select>
+
+ <select id="GetAccountViaColumnIndex"
+ parameterClass="int"
+ resultMap="indexed-account-result">
+ select
+ Account_ID,
+ Account_FirstName,
+ Account_LastName,
+ Account_Email
+ from Accounts
+ where Account_ID = #value#
+ </select>
+
+ <select id="GetAllAccountsViaResultMap"
+ resultMap="account-result">
+ select * from Accounts
+ order by Account_ID
+ </select>
+
+ <select id="GetAllAccountsViaResultClass"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ order by Account_ID
+ </select>
+
+ <select id="GetFewAccountsViaResultMap"
+ resultMap="account-result">
+ <![CDATA[
+ select * from Accounts
+ where Account_ID < 2
+ order by Account_ID
+ ]]>
+ </select>
+
+ <select id="GetNoAccountsViaResultMap"
+ resultMap="account-result">
+ select * from Accounts
+ where Account_ID > 1000
+ order by Account_ID
+ </select>
+
+
+ <select id="GetAccountNullableEmail"
+ resultMap="account-result-nullable-email">
+ select
+ Account_ID,
+ Account_FirstName,
+ Account_LastName,
+ Account_Email
+ from Accounts
+ where Account_ID = #value#
+ </select>
+
+ <select id="GetAccountViaResultClass"
+ resultClass="Account">
+ <![CDATA[
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ where Account_ID = #value#
+ ]]>
+ </select>
+
+ <select id="GetAccountViaInlineParameters"
+ resultMap="indexed-account-result">
+ select
+ Account_ID,
+ Account_FirstName,
+ Account_LastName,
+ Account_Email
+ from Accounts
+ where Account_ID = #Id# and Account_ID = #Id#
+ </select>
+
+ <select id="GetEmailAddressViaResultClass" resultClass="string">
+ select Account_Email as value
+ from Accounts
+ where Account_ID = #value#
+ </select>
+
+ <select id="GetEmailAddressViaResultMap"
+ parameterClass="int"
+ resultMap="email-result">
+ select Account_Email
+ from Accounts
+ where Account_ID = #value#
+ </select>
+
+ <select id="GetAllEmailAddressesViaResultClass"
+ resultClass="string">
+ select Account_Email
+ from Accounts
+ order by Account_ID
+ </select>
+
+ <select id="GetAllEmailAddressesViaResultMap"
+ resultMap="email-result">
+ select Account_Email
+ from Accounts
+ order by Account_ID
+ </select>
+
+ <insert id="InsertAccountViaParameterMap"
+ parameterMap="account-insert-params">
+ insert into Accounts
+ (Account_ID, Account_FirstName, Account_LastName, Account_Email, Account_Banner_Option, Account_Cart_Option)
+ values
+ (?, ?, ?, ?, ?, ?)
+ </insert>
+
+ <update id="UpdateAccountViaParameterMap"
+ parameterMap="update-params">
+ update Accounts set
+ Account_FirstName = ?,
+ Account_LastName = ?,
+ Account_Email = ?
+ where
+ Account_ID = ?
+ </update>
+
+ <update id="UpdateAccountViaParameterMap2"
+ parameterMap="update-params2">
+ update Accounts set
+ Account_ID = ?,
+ Account_FirstName = ?,
+ Account_LastName = ?,
+ Account_Email = ?
+ where
+ Account_ID = ?
+ </update>
+
+ <delete id="DeleteAccountViaInlineParameters">
+ delete from Accounts
+ where
+ Account_ID = #Id#
+ </delete>
+
+ <select id="GetAccountComplexMapping"
+ resultMap="indexed-account-result"
+ parameterClass="array">
+ select *
+ from Accounts
+ where
+ Account_FirstName = #Account.FirstName#
+ And Account_LastName = #Order.City#
+ </select>
+
+ <select id="GetDynamicOrderedEmailAddressesViaResultMap"
+ resultMap="email-result">
+ select Account_Email
+ from Accounts
+ order by $value$
+ </select>
+
+ <!-- Dynamic statements -->
+ <select id="GetAllAccountsViaResultMapWithDynamicElement"
+ resultMap="indexed-account-result">
+ select * from Accounts
+ where Account_Email $value$ '%@%'
+ order by Account_ID
+ </select>
+
+ <select id="SimpleDynamicSubstitution"
+ parameterClass="array"
+ resultClass="Account">
+ $statement$
+ </select>
+
+ <!-- Public Fields -->
+ <insert id="InsertAccountViaPublicFields">
+ insert into Accounts
+ (Account_ID, Account_FirstName, Account_LastName, Account_Email)
+ values
+ (#Id#, #FirstName#, #LastName#, #EmailAddress#
+ )
+ </insert>
+
+ <!-- Inline Parameters -->
+ <update id="UpdateAccountViaInlineParameters"
+ parameterClass="Account">
+ update Accounts set
+ Account_FirstName = #FirstName#,
+ Account_LastName = #LastName#,
+ Account_Email = #EmailAddress, nullValue=no_email@provided.com#
+ where
+ Account_ID = #Id#
+ </update>
+
+ <insert id="InsertAccountViaInlineParameters"
+ parameterClass="Account" >
+ insert into Accounts
+ (Account_ID, Account_FirstName, Account_LastName, Account_Email)
+ values
+ (#Id#, #FirstName#, #LastName#, #EmailAddress, nullValue=no_email@provided.com#
+ )
+ </insert>
+
+ <insert id="InsertAccountNullableEmail"
+ parameterClass="Account" >
+ insert into Accounts
+ (Account_ID, Account_FirstName, Account_LastName, Account_Email)
+ values
+ ( #Id#, #FirstName#, #LastName#, #EmailAddress, dbType=VarChar# )
+ </insert>
+
+ <insert id="InsertAccountUknownParameterClass">
+ insert into Accounts
+ (Account_ID, Account_FirstName, Account_LastName, Account_Email)
+ values
+ ( #Id#, #FirstName#, #LastName#, #EmailAddress, dbType=VarChar# )
+ </insert>
+
+ <delete id="DeleteAccount" parameterClass="Account">
+ delete from Accounts
+ where Account_ID = #Id, type=integer#
+ and Account_ID = #Id, type=integer#
+ </delete>
+
+ <!-- Extends statement -->
+ <select id="GetAllAccounts"
+ resultMap="indexed-account-result">
+ select
+ Account_ID,
+ Account_FirstName,
+ Account_LastName,
+ Account_Email
+ from Accounts
+ </select>
+
+ <select id="GetAllAccountsOrderByName"
+ extends="GetAllAccounts"
+ resultMap="indexed-account-result">
+ order by Account_FirstName
+ </select>
+
+ <select id="GetOneAccount"
+ extends="GetAllAccounts"
+ resultMap="indexed-account-result">
+ where Account_ID = #value#
+ </select>
+
+ <select id="GetSomeAccount"
+ extends="GetAllAccounts"
+ parameterClass="array"
+ resultMap="indexed-account-result">
+ where Account_ID between #lowID# and #hightID#
+ </select>
+
+ <select id="SelectAccountJIRA29" parameterClass="map" resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ where Account_FirstName = '##$AccountName$##'
+ </select>
+
+ <select id="SelectAccountJIRA29-2"
+ parameterClass="array"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ where 1=1
+ <isNotEmpty prepend="AND" property="Foo">
+ (Account_FirstName = '##$Foo$##')
+ </isNotEmpty>
+ </select>
+
+ <select id="GetAccountWithRepeatingProperty"
+ parameterClass="Account"
+ resultMap="indexed-account-result">
+ select
+ Account_ID,
+ Account_FirstName,
+ Account_LastName,
+ Account_Email
+ from Accounts
+ where Account_ID = #Id# and
+ Account_ID = #Id# and
+ Account_FirstName = #FirstName# and
+ Account_LastName = #LastName# and
+ Account_ID = #Id#
+ </select>
+
+ <select id="GetAllAccountsViaCustomTypeHandler"
+ resultMap="account-result">
+ select * from Accounts
+ order by Account_ID
+ </select>
+
+ <!-- JIRA-110 -->
+ <select id="GetManyAccound" resultClass="Account">
+ <![CDATA[
+ SELECT
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ FROM Accounts
+ ]]>
+ </select>
+
+ <select id="Get1Account" extends="GetManyAccound" resultClass="Account">WHERE Account_ID=1</select>
+
+ <statement id="GetAccounts" resultMap="account-result">
+ <![CDATA[SELECT * ]]>
+ <![CDATA[FROM ]]>
+ Accounts
+ </statement>
+ <!-- JIRA-110 -->
+
+ <insert id="InsertAccountDynamic" parameterClass="Account">
+ INSERT INTO Accounts
+ (Account_ID, Account_FirstName, Account_LastName, Account_Email)
+ VALUES(#Id#, #FirstName#, #LastName#
+ <dynamic prepend=",">
+ <isNotNull prepend="," property="EmailAddress">
+ #EmailAddress#
+ </isNotNull>
+ <isNull prepend="," property="EmailAddress">
+ null
+ </isNull>
+ </dynamic>
+ )
+ </insert>
+
+ <!-- For procedure, the parameters of the parameterMap must in the same order
+ as for the procedure paramaters-->
+ <procedure id="InsertAccountViaStoreProcedure" parameterMap="account-insert-params">
+ ps_InsertAccount
+ </procedure>
+
+ <procedure id="SwapEmailAddresses" parameterMap="swap-params">
+ ps_swap_email_address
+ </procedure>
+
+ <procedure id="GetAccountViaSP" parameterMap="select-params" resultClass="Account">
+ ps_SelectAccount
+ </procedure>
+
+<!-- =============================================
+ OPTIONAL EXPLICIT PARAMETER MAP
+============================================= -->
+
+ <parameterMap id="swap-params">
+ <parameter property="email1" column="First_Email" />
+ <parameter property="email2" column="Second_Email" />
+ </parameterMap>
+
+ <parameterMap id="select-params">
+ <parameter property="Account_ID" />
+ </parameterMap>
+
+ <parameterMap id="account-insert-params">
+ <parameter property="Id" />
+ <parameter property="FirstName" />
+ <parameter property="LastName" />
+ <parameter property="EmailAddress" nullValue="no_email@provided.com"/>
+ <parameter property="BannerOptions" dbType="Varchar" type="bool"/>
+ <parameter property="CartOptions" column="Account_Cart_Option" typeHandler="HundredsBool"/>
+ </parameterMap>
+
+ <parameterMap id="update-params">
+ <parameter property="FirstName" />
+ <parameter property="LastName" />
+ <parameter property="EmailAddress" nullValue="no_email@provided.com"/>
+ <parameter property="Id" />
+ </parameterMap>
+
+ <parameterMap id="update-params2">
+ <parameter property="Id" />
+ <parameter property="FirstName" />
+ <parameter property="LastName" />
+ <parameter property="EmailAddress" nullValue="no_email@provided.com"/>
+ <parameter property="Id" />
+ </parameterMap>
+
+
+ <!-- accounts and orders -->
+
+ <select id="getAccountWithOrders" resultMap="Account-with-Orders">
+ SELECT * FROM accounts
+ LEFT JOIN orders ON
+ accounts.account_id = orders.account_id
+ </select>
+
+ <resultMap id="Account-with-Orders" class="AccountWithOrders" groupBy="Account_ID">
+ <result property="Id" column="Account_ID"/>
+ <result property="FirstName" column="Account_FirstName"/>
+ <result property="LastName" column="Account_LastName"/>
+ <result property="EmailAddress" column="Account_Email" />
+ <result property="Orders" resultMapping="account-orders" />
+ </resultMap>
+
+ <resultMap id="account-orders" class="Order">
+ <result property="Id" column="Order_Id"/>
+ <result property="Date" type="date" column="Order_Date" nullValue="0001-01-01 00:00:00"/>
+ <result property="CardExpiry" column="Order_CardExpiry"/>
+ <result property="CardType" column="Order_CardType"/>
+ <result property="CardNumber" column="Order_CardNumber"/>
+ <result property="Street" column="Order_Street"/>
+ <result property="City" column="Order_City"/>
+ <result property="Province" column="Order_Province"/>
+ <result property="PostalCode" column="Order_PostalCode"/>
+ </resultMap>
+
+ <select id="GetAccountAsHashtable"
+ parameterClass="Integer"
+ resultMap="account-hashtable-result">
+ select *
+ from Accounts
+ where Account_Id = #value#
+ </select>
+
+
+ <select id="GetAccountAsHashtableResultClass"
+ parameterClass="int"
+ resultClass="array">
+ select
+ Account_Id as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ where Account_Id = #value#
+ </select>
+
+ <select id="GetAllAccountsAsHashtableViaResultClass"
+ resultClass="array">
+ select
+ Account_Id as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ order by Account_Id
+ </select>
+
+</sqlMap> \ No newline at end of file
diff --git a/tests/unit/Data/SqlMap/maps/mssql/Category.xml b/tests/unit/Data/SqlMap/maps/mssql/Category.xml
new file mode 100644
index 00000000..6756f1fa
--- /dev/null
+++ b/tests/unit/Data/SqlMap/maps/mssql/Category.xml
@@ -0,0 +1,171 @@
+<?xml version="1.0" encoding="utf-8"?>
+<sqlMap namespace="Category" >
+
+
+ <select id="GetCategory" parameterClass="Integer" resultClass="Category">
+ select
+ Category_ID as Id,
+ Category_Name as Name,
+ Category_Guid as Guid
+ from Categories
+ where Category_ID = #value#
+ </select>
+
+
+ <!-- Test for statement as insert -->
+ <statement id="InsertCategory" parameterClass="Category" resultClass="int">
+ insert into Categories
+ (Category_Name, Category_Guid)
+ values
+ (#Name#, #Guid:UniqueIdentifier#);
+ select SCOPE_IDENTITY() as value
+ </statement><!--Guid for Oledb, UniqueIdentifier for SqlClient,Odbc -->
+
+ <!-- Test for Guid Parameter Class-->
+ <statement id="InsertCategoryGuidParameterClass" parameterClass="Guid" resultClass="int">
+ insert into Categories
+ (Category_Name, Category_Guid)
+ values
+ ('toto', #value:UniqueIdentifier#);
+ select SCOPE_IDENTITY() as value
+ </statement><!--Guid for Oledb, UniqueIdentifier for SqlClient,Odbc -->
+
+ <!-- JIRA 20 Test without specifying the dbtype-->
+ <statement id="InsertCategoryGuidParameterClassJIRA20" parameterClass="Guid" resultClass="int">
+ insert into Categories
+ (Category_Name, Category_Guid)
+ values
+ ('toto', #value#);
+ select SCOPE_IDENTITY() as value
+ </statement>
+
+ <insert id="InsertCategoryViaInsertStatement" parameterClass="Category" >
+ <selectKey property="Id" type="post" resultClass="int">
+ ${selectKey}
+ </selectKey>
+ insert into Categories
+ (Category_Name, Category_Guid)
+ values
+ (#Name#, #Guid:UniqueIdentifier#)
+ </insert><!--Guid for Oledb, UniqueIdentifier for SqlClient, Odbc -->
+
+ <insert id="InsertCategoryWithProperties" parameterClass="Category" >
+ <selectKey property="Id" type="post" resultClass="int">
+ ${selectKey}
+ </selectKey>
+ insert into Categories
+ (Category_Name, Category_Guid)
+ values
+ (${MyCategoryName}, #Guid:UniqueIdentifier#)
+ </insert>
+
+ <statement id="InsertCategoryViaParameterMap" parameterMap="InsertParam" resultClass="int">
+ insert into Categories
+ (Category_Name, Category_Guid)
+ values
+ (?,?);
+ select SCOPE_IDENTITY() as value
+ </statement>
+
+ <statement id="InsertCategoryNull" parameterMap="insert-null-params" resultClass="int">
+ insert into Categories
+ (Category_Name, Category_Guid)
+ values
+ (?,?);
+ select SCOPE_IDENTITY() as value
+ </statement>
+
+ <update id="UpdateCategoryViaParameterMap" parameterMap="UpdateParam">
+ update Categories set
+ Category_Name =?,
+ Category_Guid = ?
+ where
+ Category_Id = ?
+ </update>
+
+ <procedure id="InsertCategoryViaStoreProcedure" parameterMap="category-insert-params">
+ ps_InsertCategorie
+ </procedure>
+
+ <insert id="InsertCategoryGenerate" parameterMap="insert-generate-params">
+ <selectKey property="Id" type="post" resultClass="int">
+ select @@IDENTITY as value
+ </selectKey>
+ <generate table="Categories" />
+ </insert>
+
+ <update id="UpdateCategoryGenerate" parameterMap="update-generate-params">
+ <generate table="Categories" by="Category_Id"/>
+ </update>
+
+ <delete id="DeleteCategoryGenerate" parameterMap="delete-generate-params">
+ <generate table="Categories" by="Category_Id, Category_Name"/>
+ </delete>
+
+ <select id="SelectByPKCategoryGenerate" resultClass="Category" parameterClass="Category" parameterMap="select-generate-params">
+ <generate table="Categories" by="Category_Id"/>
+ </select>
+
+ <select id="SelectAllCategoryGenerate" resultClass="Category" parameterMap="select-generate-params">
+ <generate table="Categories" />
+ </select>
+
+ <statement id="DynamicGuid"
+ resultClass="Category"
+ parameterClass="Category">
+ select
+ Category_ID as Id,
+ Category_Name as Name,
+ Category_Guid as Guid
+ from Categories
+ <dynamic prepend="where">
+ <isNotEqual prepend="and" property="Guid" compareProperty="EmptyGuid">
+ Category_Guid=#Guid:UniqueIdentifier#
+ </isNotEqual>
+ </dynamic>
+ </statement>
+
+ <parameterMap id="category-insert-params">
+ <parameter property="Id" column="Category_Id" dbType="Int" /><!-- Int for SqlClient, Obdc; Integer for Oledb -->
+ <parameter property="Name" column="Category_Name"/>
+ <parameter property="Guid" column="Category_Guid" dbType="UniqueIdentifier"/><!--Guid for Oledb, UniqueIdentifier for SqlClient,Odbc -->
+ </parameterMap>
+
+ <parameterMap id="InsertParam">
+ <parameter property="Name" column="Category_Name"/>
+ <parameter property="Guid" column="Category_Guid" dbType="UniqueIdentifier"/><!--Guid for Oledb, UniqueIdentifier for SqlClient,Odbc -->
+ </parameterMap>
+
+ <parameterMap id="insert-null-params">
+ <parameter property="Name" column="Category_Name"/>
+ <parameter property="Guid" column="Category_Guid" nullValue="00000000-0000-0000-0000-000000000000" dbType="UniqueIdentifier"/><!--Guid for Oledb, UniqueIdentifier for SqlClient,Odbc -->
+ </parameterMap>
+
+ <parameterMap id="UpdateParam" extends="InsertParam">
+ <parameter property="Id" column="Category_Id" />
+ </parameterMap>
+
+ <!-- Used by generated statement -->
+
+ <parameterMap id="insert-generate-params">
+ <parameter property="Name" column="Category_Name"/>
+ <parameter property="Guid" column="Category_Guid" dbType="UniqueIdentifier"/><!--Guid for Oledb, UniqueIdentifier for SqlClient,Odbc -->
+ </parameterMap>
+
+ <parameterMap id="update-generate-params" extends="insert-generate-params">
+ <parameter property="Id" column="Category_Id" />
+ </parameterMap>
+
+ <parameterMap id="delete-generate-params">
+ <parameter property="Id" column="Category_Id" />
+ <parameter property="Name" column="Category_Name"/>
+ </parameterMap>
+
+ <parameterMap id="select-generate-params">
+ <parameter property="Id" column="Category_Id" />
+ <parameter property="Name" column="Category_Name"/>
+ <parameter property="Guid" column="Category_Guid" dbType="UniqueIdentifier"/>
+ </parameterMap>
+
+
+</sqlMap>
diff --git a/tests/unit/Data/SqlMap/maps/mssql/Complex.xml b/tests/unit/Data/SqlMap/maps/mssql/Complex.xml
new file mode 100644
index 00000000..91b346ca
--- /dev/null
+++ b/tests/unit/Data/SqlMap/maps/mssql/Complex.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<sqlMap namespace="Category" >
+
+
+ <statement id="ComplexMap"
+ resultClass="int" >
+ select Account_ID from Accounts where Account_ID = #obj.Map.Id#
+ </statement>
+
+ <insert id="InsertComplexAccountViaInlineDefaultNull"
+ parameterClass="array" >
+ insert into Accounts
+ (Account_ID, Account_FirstName, Account_LastName, Account_Email)
+ values
+ (#obj.Map.acct.Id#, #obj.Map.acct.FirstName#, #obj.Map.acct.LastName#, #obj.Map.acct.EmailAddress:VarChar:no_email@provided.com#
+ )
+ </insert>
+
+
+
+</sqlMap>
diff --git a/tests/unit/Data/SqlMap/maps/mssql/Document.xml b/tests/unit/Data/SqlMap/maps/mssql/Document.xml
new file mode 100644
index 00000000..de02c1ab
--- /dev/null
+++ b/tests/unit/Data/SqlMap/maps/mssql/Document.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<sqlMap namespace="Document" >
+
+ <resultMap id="document" class="Document">
+ <result property="Id" column="Document_ID"/>
+ <result property="Title" column="Document_Title"/>
+ <discriminator column="Document_Type" type="string"/>
+ <subMap value="Book" resultMapping="book" />
+ <subMap value="Newspaper" resultMapping="newspaper" />
+ </resultMap>
+
+ <resultMap id="document-custom-handler" class="Document">
+ <result property="Id" column="Document_ID"/>
+ <result property="Title" column="Document_Title"/>
+ <discriminator column="Document_Type" typeHandler="CustomInheritance"/>
+ <subMap value="Book" resultMapping="book" />
+ <subMap value="Newspaper" resultMapping="newspaper" />
+ </resultMap>
+
+ <resultMap id="book" class="Book" extends="document">
+ <result property="PageNumber" column="Document_PageNumber"/>
+ </resultMap>
+
+ <resultMap id="newspaper" class="Newspaper" extends="document">
+ <result property="City" column="Document_City"/>
+ </resultMap>
+
+ <select id="GetAllDocument"
+ resultMap="document">
+ select
+ *
+ from Documents
+ order by Document_Type, Document_ID
+ </select>
+
+ <select id="GetTypedCollection"
+ listClass="DocumentCollection"
+ resultMap="document">
+ select
+ *
+ from Documents
+ order by Document_Type, Document_ID
+ </select>
+
+ <select id="GetAllDocumentWithCustomTypeHandler"
+ resultMap="document-custom-handler">
+ select
+ *
+ from Documents
+ order by Document_Type, Document_ID
+ </select>
+
+</sqlMap> \ No newline at end of file
diff --git a/tests/unit/Data/SqlMap/maps/mssql/DynamicAccount.xml b/tests/unit/Data/SqlMap/maps/mssql/DynamicAccount.xml
new file mode 100644
index 00000000..492cd0c8
--- /dev/null
+++ b/tests/unit/Data/SqlMap/maps/mssql/DynamicAccount.xml
@@ -0,0 +1,438 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<sqlMap namespace="Account" >
+ <select id="DynamicAll"
+ parameterClass="Account"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ </select>
+
+ <select id="DynamicWithExtend"
+ extends="DynamicAll"
+ parameterClass="Account"
+ resultClass="Account">
+ <dynamic prepend="WHERE" >
+ <isGreaterThan prepend="AND" property="Id" compareValue="0" >
+ Account_ID = #Id#
+ </isGreaterThan>
+ <isNotNull prepend="AND" property="Ids" >
+ Account_ID in
+ <iterate property="Ids" open="(" close=")" conjunction="," >
+ #Ids[]#
+ </iterate>
+ </isNotNull>
+ <isNotEmpty prepend="AND" property="FirstName" >
+ Account_FirstName = #FirstName#
+ </isNotEmpty>
+ <isNotEmpty prepend="AND" property="LastName" >
+ Account_LastName = #LastName#
+ </isNotEmpty>
+ <isNotEmpty prepend="AND" property="EmailAddress" >
+ <isEqual property="EmailAddress" compareValue="Joe">
+ Account_Email = 'clinton.begin@ibatis.com'
+ </isEqual>
+ <isNotEqual property="EmailAddress" compareValue="Joe">
+ Account_Email = #EmailAddress#
+ </isNotEqual>
+ </isNotEmpty>
+ </dynamic>
+ </select>
+
+ <!-- IBATISNET-114: remapResults -->
+ <statement id="DynamicSqlOnColumnSelection"
+ parameterClass="Account"
+ resultClass="Account"
+ remapResults="true">
+ SELECT
+ Account_ID as Id,
+ <dynamic>
+ <isEqual property="LastName" compareValue="Dalton" >
+ Account_FirstName as FirstName,
+ </isEqual>
+ <isEqual property="LastName" compareValue="Dalton" >
+ Account_LastName as LastName,
+ </isEqual>
+ </dynamic>
+
+ Account_Email as EmailAddress
+ FROM
+ Accounts
+ </statement>
+
+ <statement id="DynamicIsEqual"
+ parameterClass="string"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ <isEqual compareValue="Joe" >
+ where Account_FirstName = 'Joe'
+ </isEqual>
+ </statement>
+
+ <statement id="DynamicIsParameterPresent"
+ parameterClass="integer"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ <isParameterPresent >
+ where Account_ID = #value#
+ </isParameterPresent>
+ </statement>
+
+ <statement id="DynamicIsNotEmpty"
+ parameterClass="string"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ <isNotEmpty>
+ where Account_FirstName = #value#
+ </isNotEmpty>
+ </statement>
+
+ <statement id="DynamicIsGreater"
+ parameterClass="int"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ <isGreaterThan compareValue="3" >
+ where Account_ID = 1
+ </isGreaterThan>
+ </statement>
+
+ <statement id="DynamicIsGreaterEqual"
+ parameterClass="int"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ <isGreaterEqual compareValue="3" >
+ where Account_ID = 1
+ </isGreaterEqual>
+ </statement>
+
+ <statement id="DynamicIsLess"
+ parameterClass="int"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ <isLessThan compareValue="3" >
+ where Account_ID = 1
+ </isLessThan>
+ </statement>
+
+ <statement id="DynamicIsLessEqual"
+ parameterClass="int"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ <isLessEqual compareValue="3" >
+ where Account_ID = 1
+ </isLessEqual>
+ </statement>
+
+ <statement id="DynamicIsNotNull"
+ parameterClass="string"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ <isNotNull>
+ where Account_ID = 1
+ </isNotNull>
+ </statement>
+
+ <statement id="DynamicIsPropertyAvailable"
+ parameterClass="string"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ <isPropertyAvailable property="Id" >
+ where Account_ID = 1
+ </isPropertyAvailable>
+ </statement>
+
+
+ <statement id="DynamicSubst"
+ parameterClass="map"
+ resultClass="Account">
+ <dynamic>
+ $statement$
+ </dynamic>
+ </statement>
+
+ <statement id="DynamicIterate"
+ parameterClass="list"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ WHERE Account_ID IN
+ <iterate open="(" close=")" conjunction=",">
+ #[]#
+ </iterate>
+ </statement>
+
+ <statement id="DynamicIterate2"
+ parameterClass="Account"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ WHERE Account_ID IN
+ <iterate property="Ids" open="(" close=")" conjunction="," >
+ #Ids[]#
+ </iterate>
+ </statement>
+
+ <statement id="MultiDynamicIterate"
+ parameterClass="list"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ WHERE Account_ID IN
+ <iterate open="(" close=")" conjunction=",">
+ #[]#
+ </iterate>
+ and Account_ID IN
+ <iterate open="(" close=")" conjunction=",">
+ #[]#
+ </iterate>
+ </statement>
+
+
+ <statement id="DynamicQueryByExample"
+ parameterClass="Account"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ <dynamic prepend="WHERE" >
+ <isGreaterThan prepend="AND" property="Id" compareValue="0" >
+ Account_ID = #Id#
+ </isGreaterThan>
+ <isNotNull prepend="AND" property="Ids" >
+ Account_ID in
+ <iterate property="Ids" open="(" close=")" conjunction="," >
+ #Ids[]#
+ </iterate>
+ </isNotNull>
+ <isNotEmpty prepend="AND" property="FirstName" >
+ Account_FirstName = #FirstName#
+ </isNotEmpty>
+ <isNotEmpty prepend="AND" property="LastName" >
+ Account_LastName = #LastName#
+ </isNotEmpty>
+ <isNotEmpty prepend="AND" property="EmailAddress" >
+ <isEqual property="EmailAddress" compareValue="Joe">
+ Account_Email = 'clinton.begin@ibatis.com'
+ </isEqual>
+ <isNotEqual property="EmailAddress" compareValue="Joe">
+ Account_Email = #EmailAddress#
+ </isNotEqual>
+ </isNotEmpty>
+ </dynamic>
+ </statement>
+
+ <statement id="DynamicIterateWithPrepend1"
+ parameterClass="list"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ <dynamic prepend="where" >
+ Account_ID IN
+ <iterate open="(" close=")" conjunction=",">
+ #[]#
+ </iterate>
+ </dynamic>
+ </statement>
+
+ <statement id="DynamicIterateWithPrepend2"
+ parameterClass="list"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ <dynamic prepend="where" >
+ <iterate open="(" close=")" conjunction="OR">
+ Account_ID = #[]#
+ </iterate>
+ </dynamic>
+ </statement>
+
+ <statement id="DynamicIterateWithPrepend3"
+ parameterClass="list"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ <dynamic prepend="where" >
+ <isParameterPresent prepend="BLAH!" >
+ <iterate open="(" close=")" conjunction="OR">
+ Account_ID = #[]#
+ </iterate>
+ </isParameterPresent>
+ </dynamic>
+ </statement>
+
+ <statement id="DynamicWithPrepend"
+ parameterClass="Account"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ <dynamic prepend="where">
+ <isParameterPresent>
+ <isNotEmpty prepend="and" property="Id" >
+ Account_ID = #Id#
+ </isNotEmpty>
+ <isNotEmpty prepend="and" property="FirstName" >
+ Account_FirstName = #FirstName#
+ </isNotEmpty>
+ <isNotEmpty prepend="and" property="LastName" >
+ Account_LastName = #LastName#
+ </isNotEmpty>
+ </isParameterPresent>
+ </dynamic>
+ </statement>
+
+ <statement id="DynamicWithTwoDynamicElements"
+ parameterClass="Account"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ <dynamic prepend="where">
+ <isNotEmpty prepend="BLAH!" property="Id" >
+ Account_ID = #Id#
+ </isNotEmpty>
+ </dynamic>
+ <dynamic prepend="and">
+ <isNotEmpty prepend="BLAH!" property="FirstName" >
+ Account_FirstName = #FirstName#
+ </isNotEmpty>
+ <isNotEmpty prepend="and" property="LastName" >
+ Account_LastName = #LastName#
+ </isNotEmpty>
+ </dynamic>
+ </statement>
+
+ <statement id="ComplexDynamicStatement"
+ cacheModel="account-cache"
+ resultClass="Account"
+ parameterClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ <dynamic prepend="WHERE">
+ <isNotNull prepend="AND" property="FirstName">
+ (Account_FirstName = #FirstName#
+ <isNotNull prepend="OR" property="LastName">
+ Account_LastName = #LastName#
+ </isNotNull>
+ )
+ </isNotNull>
+ <isNotNull prepend="AND" property="EmailAddress">
+ Account_Email like #EmailAddress#
+ </isNotNull>
+ <isGreaterThan prepend="AND" property="Id" compareValue="0">
+ Account_ID = #Id#
+ </isGreaterThan>
+ </dynamic>
+ order by Account_LastName
+ </statement>
+
+ <statement id="Jira-IBATISNET-11"
+ resultClass="Account"
+ parameterClass="Search">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ <dynamic prepend="where">
+ <isNotNull prepend="and" property="NumberSearch">
+ ((Account_ID $Operande$ #NumberSearch#) or
+ (Account_ID $Operande$ #NumberSearch#))
+ </isNotNull>
+ <isEqual prepend="and" property="StartDate" compareValue="25/12/2004">
+ <![CDATA[Account_FirstName >= #StartDate# ]]>
+ </isEqual>
+ <isEqual prepend="and" property="StartDateAnd" compareValue="true">
+ <![CDATA[Account_LastName >= #StartDate# ]]>
+ </isEqual>
+ </dynamic>
+
+ order by Account_LastName
+ </statement>
+</sqlMap> \ No newline at end of file
diff --git a/tests/unit/Data/SqlMap/maps/mssql/Enumeration.xml b/tests/unit/Data/SqlMap/maps/mssql/Enumeration.xml
new file mode 100644
index 00000000..c010a8eb
--- /dev/null
+++ b/tests/unit/Data/SqlMap/maps/mssql/Enumeration.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<sqlMap namespace="Enumeration" >
+
+ <resultMap id="enumeration-result" class="Enumeration" >
+ <result property="Id" column="Enum_ID"/>
+ <result property="Day" column="Enum_Day"/>
+ <result property="Color" column="Enum_Color"/>
+ <result property="Month" column="Enum_Month" nullValue="All"/>
+ </resultMap>
+
+ <select id="GetEnumerationNullValue"
+ parameterClass="Integer"
+ resultMap="enumeration-result">
+ select
+ Enum_ID,
+ Enum_Day,
+ Enum_Color,
+ Enum_Month
+ from Enumerations
+ where Enum_ID = #value#
+ </select>
+
+ <select id="GetEnumeration" parameterClass="Integer" resultClass="Enumeration">
+ select
+ Enum_ID as Id,
+ Enum_Day as Day,
+ Enum_Color as Color,
+ Enum_Month as Month
+ from Enumerations
+ where Enum_ID = #value#
+ </select>
+
+ <insert id="InsertEnumViaParameterMap" parameterMap="enum-insert-params" >
+ insert into Enumerations
+ (Enum_ID, Enum_Day, Enum_Color, Enum_Month)
+ values
+ (?, ?, ?, ?)
+ </insert>
+
+ <parameterMap id="enum-insert-params">
+ <parameter property="Id" column="Enum_ID" />
+ <parameter property="Day" column="Enum_Day"/>
+ <parameter property="Color" column="Enum_Color" />
+ <parameter property="Month" column="Enum_Month" nullValue="All"/>
+ </parameterMap>
+
+</sqlMap>
diff --git a/tests/unit/Data/SqlMap/maps/mssql/LineItem.xml b/tests/unit/Data/SqlMap/maps/mssql/LineItem.xml
new file mode 100644
index 00000000..33cb9294
--- /dev/null
+++ b/tests/unit/Data/SqlMap/maps/mssql/LineItem.xml
@@ -0,0 +1,182 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<sqlMap namespace="LineItem" >
+
+ <resultMap id="LineItem-Price" class="decimal">
+ <result property="value" column="LineItem_Price"/>
+ </resultMap>
+
+ <resultMap id="LineItem" class="LineItem">
+ <result property="Id" column="LineItem_ID"/>
+ <result property="Code" column="LineItem_Code"/>
+ <result property="Quantity" column="LineItem_Quantity"/>
+ <result property="Price" column="LineItem_Price"/>
+ </resultMap>
+
+ <resultMap id="LineItemWithNullReplacement" class="LineItem">
+ <result property="Id" column="LineItem_ID"/>
+ <result property="Code" column="LineItem_Code"/>
+ <result property="Quantity" column="LineItem_Quantity"/>
+ <result property="Price" column="LineItem_Price" nullValue="-77.77"/>
+ </resultMap>
+
+ <statement id="GetLineItemPrice"
+ parameterClass="array"
+ resultMap="LineItem-Price" >
+ select
+ LineItem_Price
+ from LineItems
+ where Order_ID = #Order_ID#
+ and LineItem_ID = #LineItem_ID#
+ </statement>
+
+ <statement id="GetLineItemsForOrder"
+ parameterClass="int"
+ listClass="TList"
+ resultClass="LineItem">
+ select
+ LineItem_ID as Id,
+ LineItem_Code as Code,
+ LineItem_Quantity as Quantity,
+ LineItem_Price as Price
+ from LineItems where Order_ID = #value#
+ </statement>
+
+ <statement id="GetLineItemsForOrderWithListClass"
+ parameterClass="int"
+ listClass="LineItemCollection"
+ resultClass="LineItem">
+ select
+ LineItem_ID as Id,
+ LineItem_Code as Code,
+ LineItem_Quantity as Quantity,
+ LineItem_Price as Price
+ from LineItems where Order_ID = #value#
+ order by LineItem_Code
+ </statement>
+
+ <statement id="GetSpecificLineItem"
+ parameterClass="array"
+ resultClass="LineItem">
+ select
+ LineItem_ID as Id,
+ LineItem_Code as Code,
+ LineItem_Quantity as Quantity,
+ LineItem_Price as Price
+ from LineItems
+ where Order_ID = #Order_ID#
+ and LineItem_ID = #LineItem_ID#
+ </statement>
+
+ <statement id="GetSpecificLineItemWithPicture"
+ parameterClass="array"
+ resultClass="LineItem">
+ select
+ LineItem_ID as Id,
+ LineItem_Code as Code,
+ LineItem_Quantity as Quantity,
+ LineItem_Price as Price,
+ LineItem_Picture as PictureData
+ from LineItems
+ where Order_ID = #Order_ID#
+ and LineItem_ID = #LineItem_ID#
+ </statement>
+
+ <select id="GetDynSpecificLineItem"
+ parameterClass="HashMap"
+ resultClass="LineItem">
+ select
+ LineItem_ID as Id,
+ LineItem_Code as Code,
+ LineItem_Quantity as Quantity,
+ LineItem_Price as Price
+ from LineItems
+ where Order_ID = #Order_ID#
+ <dynamic>
+ <isNotNull property="LineItem_ID">
+ and LineItem_ID = #LineItem_ID#
+ </isNotNull>
+ </dynamic>
+ </select>
+
+ <statement id="GetSpecificLineItemWithNullReplacement"
+ parameterClass="int"
+ resultMap="LineItemWithNullReplacement">
+ select
+ LineItem_ID,
+ LineItem_Code,
+ LineItem_Quantity,
+ LineItem_Price
+ from LineItems
+ where LineItem_ID = #value#
+ </statement>
+
+ <statement id="InsertLineItem"
+ parameterMap="lineitem-insert-params" >
+ insert into LineItems
+ (LineItem_ID, Order_ID, LineItem_Code, LineItem_Quantity, LineItem_Price)
+ values
+ (?, ?, ?, ?, ?);
+ </statement>
+
+ <statement id="InsertLineItemWithPicture"
+ parameterMap="lineitem-insert-params-picture" >
+ insert into LineItems
+ (LineItem_ID, Order_ID, LineItem_Code, LineItem_Quantity, LineItem_Price, LineItem_Picture)
+ values
+ (?, ?, ?, ?, ?, ?);
+ </statement>
+
+ <insert id="InsertLineItemPostKey" parameterClass="LineItem">
+ insert into LineItems
+ (LineItem_ID, Order_ID, LineItem_Code, LineItem_Quantity, LineItem_Price)
+ values
+ (#Id#, #Order.Id#, #Code#, #Quantity#, #Price, dbType=Decimal#)
+ <selectKey property="Id" type="post" resultClass="int" >
+ select 99 from LineItems where LineItem_ID = 1 and Order_ID=1
+ </selectKey>
+ </insert>
+
+ <insert id="InsertLineItemPreKey" parameterClass="LineItem">
+ <selectKey property="Id" type="pre" resultClass="int" >
+ select 99 from LineItems where LineItem_ID = 1 and Order_ID=1
+ </selectKey>
+ insert into LineItems
+ (LineItem_ID, Order_ID, LineItem_Code, LineItem_Quantity, LineItem_Price)
+ values
+ (#Id#, #Order.Id#, #Code#, #Quantity#, #Price, dbType=Decimal#)
+ </insert>
+
+ <insert id="InsertLineItemNoKey" parameterClass="LineItem">
+ insert into LineItems
+ (LineItem_ID, Order_ID, LineItem_Code, LineItem_Quantity, LineItem_Price)
+ values
+ (#Id#, #Order.Id#, #Code#, #Quantity#, #Price, dbType=Decimal#)
+ </insert>
+
+ <!-- JIRA 23 -->
+ <delete id="DeleteWithComments" >
+ <!-- Delete LineItems -->
+ delete from LineItems where Order_ID = 10
+ <!-- Delete LineItems -->
+ delete from LineItems where Order_ID = 9
+ </delete>
+
+ <parameterMap id="lineitem-insert-params">
+ <parameter property="Id" />
+ <parameter property="Order.Id" />
+ <parameter property="Code" />
+ <parameter property="Quantity" />
+ <parameter property="Price" dbType="Decimal" nullValue="-99.99"/>
+ </parameterMap>
+
+ <parameterMap id="lineitem-insert-params-picture">
+ <parameter property="Id" />
+ <parameter property="Order.Id" />
+ <parameter property="Code" />
+ <parameter property="Quantity" />
+ <parameter property="Price" dbType="Decimal" nullValue="-99.99"/>
+ <parameter property="PictureData" dbType="Binary" /><!-- or Image -->
+ </parameterMap>
+
+</sqlMap> \ No newline at end of file
diff --git a/tests/unit/Data/SqlMap/maps/mssql/Order.xml b/tests/unit/Data/SqlMap/maps/mssql/Order.xml
new file mode 100644
index 00000000..87a2d1a0
--- /dev/null
+++ b/tests/unit/Data/SqlMap/maps/mssql/Order.xml
@@ -0,0 +1,475 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<sqlMap namespace="Order" >
+
+
+ <resultMap id="credit-card-result" class="string">
+ <result property="value" column="Order_CardNumber"/>
+ </resultMap>
+
+ <resultMap id="order-with-lines-result" class="Order"
+ extends="lite-order-result-by-name" >
+ <result property="LineItemsList" lazyLoad="true" column="Order_ID" select="GetLineItemsForOrder" />
+ </resultMap>
+
+ <resultMap id="order-with-lines-result-statement-namespaces" class="Order"
+ extends="lite-order-result-by-name" >
+ <result property="LineItemsList" lazyLoad="true" column="Order_ID" select="LineItem.GetLineItemsForOrder" />
+ </resultMap>
+
+ <resultMap id="order-with-lines-collection" class="Order"
+ extends="lite-order-result-by-name" >
+ <result property="LineItems" column="Order_ID" select="GetLineItemsForOrderWithListClass" />
+ </resultMap>
+
+ <resultMap id="order-with-lines-array" class="Order"
+ extends="lite-order-result-by-name">
+ <result property="LineItemsArray" column="Order_ID" select="GetLineItemsForOrder"/>
+ </resultMap>
+
+ <resultMap id="lite-order-map-result" class="array">
+ <result property="Id" type="Int" column="Order_ID"/>
+ <result property="Date" type="date" column="Order_Date"/>
+ <result property="CardExpiry" type="string" column="Order_CardExpiry"/>
+ <result property="CardType" type="string" column="Order_CardType"/>
+ <result property="CardNumber" type="string" column="Order_CardNumber"/>
+ <result property="Street" type="string" column="Order_Street"/>
+ <result property="City" type="string" column="Order_City"/>
+ <result property="Province" type="string" column="Order_Province"/>
+ <result property="PostalCode" type="string" column="Order_PostalCode"/>
+ </resultMap>
+
+ <resultMap id="lite-order-result-by-name" class="Order">
+ <result property="Id" column="Order_ID"/>
+ <result property="Date" type="date" column="Order_Date" nullValue="0001-01-01 00:00:00"/>
+ <result property="CardExpiry" column="Order_CardExpiry"/>
+ <result property="CardType" column="Order_CardType"/>
+ <result property="CardNumber" column="Order_CardNumber"/>
+ <result property="Street" column="Order_Street"/>
+ <result property="City" column="Order_City"/>
+ <result property="Province" column="Order_Province"/>
+ <result property="PostalCode" column="Order_PostalCode"/>
+ </resultMap>
+
+ <resultMap id="order-with-types-result" class="Order">
+ <result property="Id" column="Order_ID" dbType="Int"/><!-- Int for SqlClient, Obdc; Integer for Oledb -->
+ <result property="Date" type="date" column="Order_Date" dbType="DateTime "/>
+ <result property="CardExpiry" column="Order_CardExpiry" dbType="VarChar"/>
+ <result property="CardType" column="Order_CardType" dbType="VarChar"/>
+ <result property="CardNumber" column="Order_CardNumber" dbType="VarChar"/>
+ <result property="Street" column="Order_Street" dbType="VarChar"/>
+ <result property="City" column="Order_City" dbType="VarChar"/>
+ <result property="Province" column="Order_Province" dbType="VarChar"/>
+ <result property="PostalCode" column="Order_PostalCode" dbType="VarChar"/>
+ </resultMap>
+
+ <resultMap id="lite-order-result-by-index" class="Order">
+ <result property="Id" column="Order_ID" columnIndex="0"/>
+ <result property="Date" type="date" column="Order_Date" columnIndex="1" />
+ <result property="CardExpiry" column="Order_CardExpiry" columnIndex="2"/>
+ <result property="CardType" column="Order_CardType" columnIndex="3" />
+ <result property="CardNumber" column="Order_CardNumber" columnIndex="4" />
+ <result property="Street" column="Order_Street" columnIndex="5" />
+ <result property="City" column="Order_City" columnIndex="6" />
+ <result property="Province" column="Order_Province" columnIndex="7"/>
+ <result property="PostalCode" column="Order_PostalCode" columnIndex="8" />
+ </resultMap>
+
+ <resultMap id="order-with-account-result" class="Order">
+ <result property="Id" column="Order_ID"/>
+ <result property="Date" type="date" column="Order_Date"/>
+ <result property="CardExpiry" column="Order_CardExpiry"/>
+ <result property="CardType" column="Order_CardType"/>
+ <result property="CardNumber" column="Order_CardNumber"/>
+ <result property="Street" column="Order_Street"/>
+ <result property="City" column="Order_City"/>
+ <result property="Province" column="Order_Province"/>
+ <result property="PostalCode" column="Order_PostalCode"/>
+ <result property="Account" column="Account_ID" select="GetAccountViaColumnName" />
+ </resultMap>
+
+ <resultMap id="order-with-sp-account-result" class="Order">
+ <result property="Id" column="Order_ID"/>
+ <result property="Date" type="date" column="Order_Date"/>
+ <result property="CardExpiry" column="Order_CardExpiry"/>
+ <result property="CardType" column="Order_CardType"/>
+ <result property="CardNumber" column="Order_CardNumber"/>
+ <result property="Street" column="Order_Street"/>
+ <result property="City" column="Order_City"/>
+ <result property="Province" column="Order_Province"/>
+ <result property="PostalCode" column="Order_PostalCode"/>
+ <result property="Account" column="Account_ID=Account_ID" select="GetAccountViaSP" />
+ </resultMap>
+
+ <resultMap id="order-with-collection-result" class="Order">
+ <result property="Id" column="Order_ID"/>
+ <result property="Date" type="date" column="Order_Date"/>
+ <result property="CardExpiry" column="Order_CardExpiry"/>
+ <result property="CardType" column="Order_CardType"/>
+ <result property="CardNumber" column="Order_CardNumber"/>
+ <result property="Street" column="Order_Street"/>
+ <result property="City" column="Order_City"/>
+ <result property="Province" column="Order_Province"/>
+ <result property="PostalCode" column="Order_PostalCode"/>
+ <result property="LineItemsList" column="Order_ID" select="GetLineItemsForOrder" />
+ <result property="LineItems" column="Order_ID" select="GetLineItemsForOrder" lazyLoad="false" />
+ </resultMap>
+
+ <resultMap id="order-with-favourite-line-item" class="Order">
+ <result property="Id" column="Order_ID"/>
+ <result property="Date" type="date" column="Order_Date"/>
+ <result property="CardExpiry" column="Order_CardExpiry"/>
+ <result property="CardType" column="Order_CardType"/>
+ <result property="CardNumber" column="Order_CardNumber"/>
+ <result property="Street" column="Order_Street"/>
+ <result property="City" column="Order_City"/>
+ <result property="Province" column="Order_Province"/>
+ <result property="PostalCode" column="Order_PostalCode"/>
+ <result property="FavouriteLineItem" column="Order_ID=Order_ID,LineItem_ID=Order_FavouriteLineItem" select="GetSpecificLineItem" />
+ </resultMap>
+
+ <resultMap id="order-with-dyn-favourite-line-item" class="Order">
+ <result property="Id" column="Order_ID"/>
+ <result property="Date" type="date" column="Order_Date"/>
+ <result property="CardExpiry" column="Order_CardExpiry"/>
+ <result property="CardType" column="Order_CardType"/>
+ <result property="CardNumber" column="Order_CardNumber"/>
+ <result property="Street" column="Order_Street"/>
+ <result property="City" column="Order_City"/>
+ <result property="Province" column="Order_Province"/>
+ <result property="PostalCode" column="Order_PostalCode"/>
+ <result property="FavouriteLineItem"
+ column="Order_ID=Order_ID,LineItem_ID=Order_FavouriteLineItem"
+ select="GetDynSpecificLineItem" />
+ </resultMap>
+ <resultMap id="order-joined-favourite" class="Order">
+ <result property="Id" column="Order_ID"/>
+ <result property="Date" type="date" column="Order_Date"/>
+ <result property="CardExpiry" column="Order_CardExpiry"/>
+ <result property="CardType" column="Order_CardType"/>
+ <result property="CardNumber" column="Order_CardNumber"/>
+ <result property="Street" column="Order_Street"/>
+ <result property="City" column="Order_City"/>
+ <result property="Province" column="Order_Province"/>
+ <result property="PostalCode" column="Order_PostalCode"/>
+ <result property="FavouriteLineItem" resultMapping="LineItem" />
+ </resultMap>
+
+ <resultMap id="order-joined-favourite2" class="Order">
+ <result property="Id" column="Order_ID"/>
+ <result property="Date" type="date" column="Order_Date"/>
+ <result property="CardExpiry" column="Order_CardExpiry"/>
+ <result property="CardType" column="Order_CardType"/>
+ <result property="CardNumber" column="Order_CardNumber"/>
+ <result property="Street" column="Order_Street"/>
+ <result property="City" column="Order_City"/>
+ <result property="Province" column="Order_Province"/>
+ <result property="PostalCode" column="Order_PostalCode"/>
+ <result property="FavouriteLineItem.Id" column="LineItem_ID"/>
+ <result property="FavouriteLineItem.Code" column="LineItem_Code"/>
+ <result property="FavouriteLineItem.Quantity" column="LineItem_Quantity"/>
+ <result property="FavouriteLineItem.Price" column="LineItem_Price"/>
+ </resultMap>
+
+ <resultMap id="order-joined-with-account" class="Order">
+ <result property="Id" column="Order_ID"/>
+ <result property="Date" type="date" column="Order_Date" nullValue="0001-01-01 00:00:00"/>
+ <result property="CardExpiry" column="Order_CardExpiry"/>
+ <result property="CardType" column="Order_CardType"/>
+ <result property="CardNumber" column="Order_CardNumber"/>
+ <result property="Street" column="Order_Street"/>
+ <result property="City" column="Order_City"/>
+ <result property="Province" column="Order_Province"/>
+ <result property="PostalCode" column="Order_PostalCode"/>
+ <result property="Account" resultMapping="account-result-nullable-email" />
+ </resultMap>
+
+ <resultMap id="order-hash" class="array">
+ <result property="Date" column="Order_Date" nullValue="0001-01-01 00:00:00"/>
+ </resultMap>
+
+ <statement id="GetOrderByHashTable"
+ parameterClass="Int"
+ resultMap="order-hash" >
+ select Order_Date from Orders where Order_ID = #value#
+ </statement>
+
+ <statement id="GetOrderLiteByColumnName"
+ parameterClass="Int"
+ resultMap="lite-order-result-by-name" >
+ select * from Orders where Order_ID = #value#
+ </statement>
+
+ <statement id="GetOrderLiteByColumnIndex"
+ parameterClass="Int"
+ resultMap="lite-order-result-by-index" >
+ select
+ Order_ID,
+ Order_Date,
+ Order_CardExpiry,
+ Order_CardType,
+ Order_CardNumber,
+ Order_Street,
+ Order_City,
+ Order_Province,
+ Order_PostalCode
+ from Orders where Order_ID = #value#
+ </statement>
+
+ <statement id="GetOrderWithTypes"
+ parameterClass="Int"
+ resultMap="order-with-types-result" >
+ select * from Orders where Order_ID = #value#
+ </statement>
+
+ <statement id="GetOrderWithLineItems"
+ parameterClass="Integer"
+ resultMap="order-with-lines-result" >
+ select * from Orders where Order_ID = #value#
+ </statement>
+
+ <statement id="GetOrderWithLineItemsUsingStatementNamespaces"
+ parameterClass="Integer"
+ resultMap="order-with-lines-result-statement-namespaces" >
+ select * from Orders where Order_ID = #value#
+ </statement>
+
+ <statement id="GetAllOrderWithLineItems"
+ parameterClass="Integer"
+ resultMap="order-with-lines-result" >
+ select * from Orders
+ </statement>
+
+ <statement id="GetOrderCardExpiryViaResultClass"
+ parameterClass="int"
+ resultClass="date">
+ select
+ Order_Date as datetime
+ from Orders where Order_ID = #value#
+ </statement>
+
+ <statement id="GetOrderWithAccount"
+ parameterClass="int"
+ resultMap="order-with-account-result" >
+ select * from Orders where Order_ID = #value#
+ </statement>
+
+ <statement id="GetOrderWithAccountViaSP"
+ parameterClass="int"
+ resultMap="order-with-sp-account-result" >
+ select * from Orders where Order_ID = #value#
+ </statement>
+
+ <statement id="GetOrderWithLineItemsCollection"
+ parameterClass="Integer"
+ resultMap="order-with-collection-result" >
+ select * from Orders where Order_ID = #value#
+ </statement>
+
+ <statement id="GetOrderJoinedFavourite"
+ parameterClass="Integer"
+ resultMap="order-joined-favourite" >
+ select * from Orders, LineItems
+ where Orders.Order_ID = LineItems.Order_ID
+ and Order_FavouriteLineItem = LineItems.LineItem_ID
+ and Orders.Order_ID = #value#
+ </statement>
+
+ <statement id="GetOrderJoinedFavourite2"
+ parameterClass="Integer"
+ resultMap="order-joined-favourite2" >
+ select * from Orders, LineItems
+ where Orders.Order_ID = LineItems.Order_ID
+ and Order_FavouriteLineItem = LineItems.LineItem_ID
+ and Orders.Order_ID = #value#
+ </statement>
+
+ <statement id="GetOrderJoinedFavourite3"
+ parameterClass="Integer"
+ resultClass="Order" >
+ select
+ Orders.Order_ID as Id,
+ Order_Date as Date,
+ Order_CardExpiry as CardExpiry,
+ Order_CardType as CardType,
+ Order_CardNumber as CardNumber,
+ Order_Street as Street,
+ Order_City as City,
+ Order_Province as Province,
+ Order_PostalCode as PostalCode,
+ LineItem_ID as "FavouriteLineItem.Id",
+ LineItem_Code as "FavouriteLineItem.Code",
+ LineItem_Quantity as "FavouriteLineItem.Quantity",
+ LineItem_Price as "FavouriteLineItem.Price"
+ from Orders, LineItems
+ where Orders.Order_ID = LineItems.Order_ID
+ and Order_FavouriteLineItem = LineItems.LineItem_ID
+ and Orders.Order_ID = #value#
+ </statement>
+
+ <statement id="GetOrderWithFavouriteLineItem"
+ parameterClass="int"
+ resultMap="order-with-favourite-line-item" >
+ select * from Orders where Order_ID = #value#
+ </statement>
+
+ <statement id="GetOrderWithLineItemCollection"
+ parameterClass="int"
+ resultMap="order-with-lines-collection" >
+ select * from Orders where Order_ID = #value#
+ </statement>
+
+ <statement id="GetOrderAsHastable"
+ parameterClass="Integer"
+ resultMap="lite-order-map-result" >
+ select * from Orders where Order_ID = #value#
+ </statement>
+
+ <statement id="GetOrderWithLineItemArray"
+ parameterClass="int"
+ resultMap="order-with-lines-array">
+ select * from Orders where Order_ID = #value#
+ </statement>
+
+ <statement id="GetAllCreditCardNumbersFromOrders"
+ resultMap="credit-card-result" >
+ select distinct Order_CardNumber from Orders
+ order by Order_CardNumber
+ </statement>
+
+ <statement id="InsertOrderViaParameterMap"
+ parameterMap="order-insert-params" >
+ insert into Orders
+ (Order_ID, Account_ID, Order_Date, Order_CardExpiry, Order_CardType,
+ Order_CardNumber, Order_Street, Order_City, Order_Province, Order_PostalCode )
+ values
+ (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
+ </statement>
+
+ <statement id="InsertOrderViaExtendParameterMap"
+ parameterMap="insert-extend" >
+ insert into Orders
+ (Order_ID, Account_ID, Order_Date, Order_CardExpiry, Order_CardType,
+ Order_CardNumber, Order_Street, Order_City, Order_Province, Order_PostalCode )
+ values
+ (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
+ </statement>
+
+ <statement id="InsertOrderViaPublicFields">
+ insert into Orders
+ (Order_ID, Account_ID, Order_Date, Order_CardExpiry, Order_CardType,
+ Order_CardNumber, Order_Street, Order_City, Order_Province, Order_PostalCode )
+ values
+ (#Id#, #Account.Id#, #Date#, #CardExpiry#, #CardType#, #CardNumber#, #Street#, #City#, #Province#, #PostalCode#)
+ </statement>
+
+ <select id="GetOrderWithDynFavouriteLineItem"
+ parameterClass="Integer"
+ resultMap="order-with-dyn-favourite-line-item">
+ select * from Orders where Order_ID = #value#
+ </select>
+
+ <select id="SelectOrderByDate"
+ parameterClass="array"
+ resultMap="lite-order-result-by-name">
+ select * from Orders where Order_Date = #Foo#
+ </select>
+
+ <select id="SelectOrderByDateDynamic"
+ parameterClass="array"
+ resultMap="lite-order-result-by-name">
+ select * from Orders
+ where 1=1
+ <isNotEmpty prepend="AND" property="Foo">
+ (Order_Date = '$Foo$')
+ </isNotEmpty>
+ </select>
+
+ <select id="GetAccountJIRA45"
+ parameterClass="int"
+ resultMap="indexed-account-result">
+ select
+ Account_ID,
+ Account_FirstName,
+ Account_LastName,
+ Account_Email
+ from Accounts
+ where Account_ID = #value#
+ </select>
+
+ <select id="GetOrderJoinWithAccount"
+ parameterClass="Integer"
+ resultMap="order-joined-with-account">
+ select
+ Order_ID,
+ Order_Date,
+ Order_CardExpiry,
+ Order_CardType,
+ Order_CardNumber,
+ Order_Street,
+ Order_City,
+ Order_Province,
+ Order_PostalCode,
+ acc.Account_ID,
+ acc.Account_FirstName,
+ acc.Account_LastName,
+ acc.Account_Email
+ from Orders as ord
+ LEFT OUTER JOIN Accounts as acc on acc.Account_ID = ord.Account_ID
+ where Order_ID = #value#
+ </select>
+
+
+ <parameterMap id="order-insert-params">
+ <parameter property="Id" dbType="Int"/> <!-- Int for SqlClient, Obdc; Integer for Oledb -->
+ <parameter property="Account.Id" type="integer"/>
+ <parameter property="Date" type="date" nullValue="0001-01-01 00:00:00" />
+ <parameter property="CardExpiry" />
+ <parameter property="CardType" />
+ <parameter property="CardNumber" />
+ <parameter property="Street" />
+ <parameter property="City" />
+ <parameter property="Province" />
+ <parameter property="PostalCode" />
+ </parameterMap>
+
+ <parameterMap id="params-parent"> <!-- 1043181 support request -->
+ <parameter property="Id" dbType="Int"/>
+ <parameter property="Account.Id"/>
+ <parameter property="Date" type="date" nullValue="0001-01-01 00:00:00" />
+ <parameter property="CardExpiry" />
+ <parameter property="CardType" />
+ <parameter property="CardNumber" />
+ <parameter property="Street" />
+ <parameter property="City" />
+ <parameter property="Province" />
+ <parameter property="PostalCode" />
+ </parameterMap>
+
+ <parameterMap id="insert-extend" extends="params-parent">
+ </parameterMap>
+
+ <statement id="GetOrderWithLineItemsNoLazyLoad"
+ parameterClass="Integer"
+ resultMap="order-with-lines-result-no-lazy-load" >
+ select * from Orders where Order_ID = #value#
+ </statement>
+
+ <resultMap id="order-with-lines-result-no-lazy-load" class="Order"
+ extends="lite-order-result-by-name" >
+ <result property="LineItemsList" type="TList" column="Order_ID" select="GetLineItemsForOrder" />
+ </resultMap>
+
+ <statement id="GetOrderWithLineItemCollectionNoLazy"
+ parameterClass="int"
+ resultMap="order-with-lines-collection-no-lazy-load" >
+ select * from Orders where Order_ID = #value#
+ </statement>
+
+ <resultMap id="order-with-lines-collection-no-lazy-load" class="Order"
+ extends="lite-order-result-by-name" >
+ <result property="LineItems" column="Order_ID"
+ select="GetLineItemsForOrderWithListClass" />
+ </resultMap>
+
+</sqlMap> \ No newline at end of file
diff --git a/tests/unit/Data/SqlMap/maps/mssql/Other.xml b/tests/unit/Data/SqlMap/maps/mssql/Other.xml
new file mode 100644
index 00000000..5d64f357
--- /dev/null
+++ b/tests/unit/Data/SqlMap/maps/mssql/Other.xml
@@ -0,0 +1,171 @@
+<?xml version="1.0" encoding="utf-8"?>
+<sqlMap namespace="Other" >
+
+ <resultMap id="other-result" class="Other" >
+ <result property="Int" column="Other_Int"/>
+ <result property="Long" column="Other_Long"/>
+ <result property="Bool" column="Other_Bit"/>
+ <result property="Bool2" column="Other_String" typeHandler="OuiNonBool"/>
+ </resultMap>
+
+ <resultMap id="A-result" class="A" >
+ <result property="Id" column="A_ID"/>
+ <result property="Libelle" column="A_Libelle"/>
+ <result property="B" resultMapping="B-result"/>
+ <result property="E" resultMapping="E-result"/>
+ <result property="F" resultMapping="F-result"/>
+ </resultMap>
+
+ <resultMap id="B-result" class="B" >
+ <result property="Id" column="B_ID"/>
+ <result property="Libelle" column="B_Libelle"/>
+ <result property="C" resultMapping="C-result"/>
+ <result property="D" resultMapping="D-result"/>
+ </resultMap>
+
+ <resultMap id="C-result" class="C" >
+ <result property="Id" column="C_ID"/>
+ <result property="Libelle" column="C_Libelle"/>
+ </resultMap>
+
+ <resultMap id="D-result" class="D" >
+ <result property="Id" column="D_ID"/>
+ <result property="Libelle" column="D_Libelle"/>
+ </resultMap>
+
+ <resultMap id="E-result" class="E" >
+ <result property="Id" column="E_ID"/>
+ <result property="Libelle" column="E_Libelle"/>
+ </resultMap>
+
+ <resultMap id="F-result" class="F" >
+ <result property="Id" column="F_ID"/>
+ <result property="Libelle" column="F_Libelle"/>
+ </resultMap>
+
+ <select id="SelectComplexJoined" resultMap="A-result">
+ SELECT
+ A.Id AS A_ID,
+ A.A_Libelle AS A_Libelle,
+ B.ID AS B_ID,
+ B.B_Libelle AS B_Libelle,
+ C.ID AS C_ID,
+ C.C_Libelle AS C_Libelle,
+ D.ID AS D_ID,
+ D.D_Libelle AS D_Libelle,
+ E.ID AS E_ID,
+ E.E_Libelle AS E_Libelle,
+ F.ID AS F_ID,
+ F.F_Libelle AS F_Libelle
+ FROM A
+ LEFT OUTER JOIN B ON A.B_ID = B.ID
+ LEFT OUTER JOIN C ON B.C_ID = C.ID
+ LEFT OUTER JOIN D ON B.D_ID = D.ID
+ LEFT OUTER JOIN E ON A.E_ID = E.ID
+ LEFT OUTER JOIN F ON A.F_ID = F.ID
+ </select>
+ <statement id="DynamicSelectByIntLong"
+ parameterClass="array"
+ resultMap="other-result">
+ select
+ Other_Int,
+ Other_Long,
+ Other_Bit,
+ Other_String
+ from Others
+ <dynamic prepend="WHERE">
+ <isNotEqual prepend="AND" property="year" compareValue="0">
+ Other_Int = #year#
+ </isNotEqual>
+
+ <isNotEqual prepend="AND" property="areaid" compareValue="0">
+ Other_Long = #areaid#
+ </isNotEqual>
+ </dynamic>
+ </statement>
+
+ <statement id="DynamicSelectByBool"
+ parameterClass="Other"
+ resultMap="other-result">
+ select
+ Other_Int,
+ Other_Long,
+ Other_Bit,
+ Other_String
+ from Others
+ Where Other_Bit = #Bool#
+ </statement>
+
+ <statement id="InsertBool"
+ parameterClass="Other">
+ Insert into Others
+ ( Other_Int, Other_Long, Other_Bit, Other_String )
+ values
+ ( #Int#, #Long#, #Bool#, 'Yes')
+ </statement>
+
+ <statement id="InsertCustomTypeHandler"
+ parameterMap="other-insert-params">
+ Insert into Others
+ ( Other_Int, Other_Long, Other_Bit, Other_String )
+ values
+ ( ?, ?, ?, ?)
+ </statement>
+
+ <statement id="SelectByInt"
+ parameterClass="int"
+ resultMap="other-result">
+ select
+ Other_Int,
+ Other_Long,
+ Other_Bit,
+ Other_String
+ from Others
+ Where Other_Int = #value#
+ </statement>
+
+ <statement id="InsertInlineCustomTypeHandlerV1"
+ parameterClass="Other">
+ Insert into Others
+ ( Other_Int, Other_Long, Other_Bit, Other_String )
+ values
+ ( #Int#, #Long#, #Bool#, #Bool2,type=bool,dbType=Varchar#)
+ </statement>
+
+ <statement id="InsertInlineCustomTypeHandlerV2"
+ parameterClass="Other">
+ Insert into Others
+ ( Other_Int, Other_Long, Other_Bit, Other_String )
+ values
+ ( #Int#, #Long#, #Bool#, #Bool2,typeHandler=OuiNonBool#)
+ </statement>
+
+ <parameterMap id="other-insert-params">
+ <parameter property="Int" />
+ <parameter property="Long" />
+ <parameter property="Bool" />
+ <parameter property="Bool2" typeHandler="OuiNonBool"/>
+ </parameterMap>
+
+
+ <statement id="SelectByIntV1"
+ parameterClass="int"
+ resultMap="other-result-V1">
+ select
+ Other_Int,
+ Other_Long,
+ Other_Bit,
+ Other_String
+ from Others
+ Where Other_Int = #value#
+ </statement>
+
+
+ <resultMap id="other-result-V1" class="Other" >
+ <result property="Int" column="Other_Int"/>
+ <result property="Long" column="Other_Long"/>
+ <result property="Bool" column="Other_Bit"/>
+ <result property="Bool2" column="Other_String" />
+ </resultMap>
+
+</sqlMap>
diff --git a/tests/unit/Data/SqlMap/maps/mssql/ResultClass.xml b/tests/unit/Data/SqlMap/maps/mssql/ResultClass.xml
new file mode 100644
index 00000000..ac705ac1
--- /dev/null
+++ b/tests/unit/Data/SqlMap/maps/mssql/ResultClass.xml
@@ -0,0 +1,125 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<sqlMap namespace="ResultClass" >
+
+ <statement id="GetBoolean"
+ parameterClass="Int"
+ resultClass="bool" >
+ select cast(1 as bit) from Orders where Order_ID = #dummy#
+ </statement>
+ <statement id="GetBooleanWithoutResultClass"
+ parameterClass="Int"
+ extends="GetBoolean">
+ </statement>
+
+ <statement id="GetByte"
+ parameterClass="Int"
+ resultClass="int" >
+ select cast(155 as tinyint) from Orders where Order_ID = #value#
+ </statement>
+ <statement id="GetByteWithoutResultClass"
+ parameterClass="Int"
+ extends="GetByte">
+ </statement>
+
+ <statement id="GetChar"
+ parameterClass="Int"
+ resultClass="string" >
+ select cast('a' as char) from Orders where Order_ID = #value#
+ </statement>
+ <!-- SQL Server provider doesn't know char type, the resultClass type must be specified -->
+ <statement id="GetCharWithoutResultClass"
+ parameterClass="Int" resultClass="string"
+ extends="GetChar">
+ </statement>
+
+ <statement id="GetDate"
+ parameterClass="Int"
+ resultClass="date" >
+ select cast('2003-02-15 8:15:00' as datetime) as datetime from Orders where Order_ID = #value#
+ </statement>
+ <statement id="GetDateWithoutResultClass"
+ parameterClass="Int"
+ extends="GetDate">
+ </statement>
+
+ <statement id="GetDecimal"
+ parameterClass="Int"
+ resultClass="decimal" >
+ select cast(1.56 as decimal(9,2)) from Orders where Order_ID = #value#
+ </statement>
+ <statement id="GetDecimalWithoutResultClass"
+ parameterClass="Int"
+ extends="GetDecimal">
+ </statement>
+
+ <statement id="GetDouble"
+ parameterClass="Int"
+ resultClass="double" >
+ select cast(99.5 as float) from Orders where Order_ID= #value#
+ </statement>
+ <statement id="GetDoubleWithoutResultClass"
+ parameterClass="Int"
+ extends="GetDouble">
+ </statement>
+
+ <statement id="GetGuid"
+ parameterClass="Int"
+ resultClass="guid" >
+ select cast('CD5ABF17-4BBC-4C86-92F1-257735414CF4' as UniqueIdentifier) from Orders where Order_ID = #value#
+ </statement>
+ <statement id="GetGuidWithoutResultClass" parameterClass="Int" extends="GetGuid">
+ </statement>
+
+ <statement id="GetInt16"
+ parameterClass="Int"
+ resultClass="integer" >
+ select cast(32111 as SmallInt) from Orders where Order_ID = #value#
+ </statement>
+ <statement id="GetInt16WithoutResultClass"
+ parameterClass="Int"
+ extends="GetInt16">
+ </statement>
+
+ <statement id="GetInt32"
+ parameterClass="Int"
+ resultClass="int" >
+ select cast(999999 as int) from Orders where Order_ID = #value#
+ </statement>
+ <statement id="GetInt32WithoutResultClass"
+ parameterClass="Int"
+ extends="GetInt32">
+ </statement>
+
+ <statement id="GetInt64"
+ parameterClass="Int"
+ resultClass="float" >
+ select cast(9223372036854775800 as bigint) from Orders where Order_ID = #value#
+ </statement>
+ <statement id="GetInt64WithoutResultClass"
+ parameterClass="Int"
+ extends="GetInt64">
+ </statement>
+
+ <statement id="GetSingle"
+ parameterClass="Int"
+ resultClass="float" >
+ select cast(92233.5 as real) from Orders where Order_ID = #value#
+ </statement>
+ <statement id="GetSingleWithoutResultClass"
+ parameterClass="Int"
+ extends="GetSingle">
+ </statement>
+
+ <statement id="GetString"
+ parameterClass="Int"
+ resultClass="string" >
+ select 'VISA'
+ from Orders where Order_ID = #value#
+ </statement>
+ <statement id="GetStringWithoutResultClass"
+ parameterClass="Int"
+ extends="GetString">
+ </statement>
+
+</sqlMap> \ No newline at end of file
diff --git a/tests/unit/Data/SqlMap/maps/sqlite/Account.xml b/tests/unit/Data/SqlMap/maps/sqlite/Account.xml
new file mode 100644
index 00000000..aa175459
--- /dev/null
+++ b/tests/unit/Data/SqlMap/maps/sqlite/Account.xml
@@ -0,0 +1,641 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<sqlMap namespace="Account" >
+
+ <!-- =============================================
+ <resultMap
+ name="name"
+ class="name"
+ extend="resultMapId"
+ >
+ <result
+ property="name"
+ column="name"
+ columnIndex="name"
+ nullValue="value"
+ select="name"
+ resultMap="name"
+ lazyLoad="true/false"
+ dbType=""
+ />
+ <procedure
+ name="name"
+ parameterMap="name"
+ >
+ <statement
+ name="name"
+ parameterClass="name"
+ parameterMap="name"
+ resultClass="name"
+ resultMap="name"
+ listClass="name"
+ >
+ <parameterMap
+ name="name"
+ class=""
+ >
+ <parameter
+ property="name"
+ dbType=""
+ output="true/false"
+ type=""
+ nullValue=""
+ extend="parameterMapId"
+ />
+
+ ============================================= -->
+
+ <cacheModel id="account-cache" implementation="LRU" >
+ <flushInterval hours="24"/>
+ <flushOnExecute statement="UpdateAccountViaInlineParameters"/>
+ <flushOnExecute statement="UpdateAccountViaParameterMap"/>
+ <property name="size" value="10"/>
+ </cacheModel>
+
+ <!--
+ <cacheModel name="account-cache" implementation="LRU" >
+ <flushInterval hours="24"/>
+ <flushOnExecute statement="UpdateAccountViaInlineParameters"/>
+ <flushOnExecute statement="UpdateAccountViaParameterMap"/>
+ <property name="CacheSize" value="50"/>
+ </cacheModel>
+ -->
+
+
+ <alias>
+ <typeAlias alias="HundredsBool" type="IBatisNet.DataMapper.Test.Domain.HundredsTypeHandlerCallback, IBatisNet.DataMapper.Test"/>
+ </alias>
+
+ <resultMap id="account-result" class="Account" >
+ <result property="Id" column="Account_Id"/>
+ <result property="FirstName" column="Account_FirstName"/>
+ <result property="LastName" column="Account_LastName"/>
+ <result property="EmailAddress" column="Account_Email" nullValue="no_email@provided.com"/>
+ <result property="BannerOptions" column="Account_Banner_Option" typeHandler="OuiNonBool"/>
+ <result property="CartOptions" column="Account_Cart_Option" typeHandler="HundredsBool"/>
+ </resultMap>
+ <resultMap id="indexed-account-result" class="Account">
+ <result property="Id" column="Account_Id" columnIndex="0"/>
+ <result property="FirstName" column="Account_FirstName" columnIndex="1"/>
+ <result property="LastName" column="Account_LastName" columnIndex="2"/>
+ <result property="EmailAddress" column="Account_Email" columnIndex="3" nullValue="no_email@provided.com"/>
+ </resultMap>
+ <resultMap id="account-result-nullable-email" class="Account">
+ <result property="Id" column="Account_Id"/>
+ <result property="FirstName" column="Account_FirstName"/>
+ <result property="LastName" column="Account_LastName"/>
+ <result property="EmailAddress" column="Account_Email"/>
+ </resultMap>
+
+ <resultMap id="email-result" class="string">
+ <result property="value" column="Account_Email"/>
+ </resultMap>
+
+ <resultMap id="account-hashtable-result" class="array">
+ <result property="Id" column="Account_Id"/>
+ <result property="FirstName" column="Account_FirstName"/>
+ <result property="LastName" column="Account_LastName"/>
+ <result property="EmailAddress" column="Account_Email"/>
+ </resultMap>
+
+
+ <!-- =============================================
+ MAPPED STATEMENTS - w/Inline Parameters
+ =============================================
+ -->
+
+ <select id="GetAllAccountsAsArrayListViaResultClass"
+ resultClass="TList">
+ select
+ Account_Id as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ order by Account_Id
+ </select>
+
+ <select id="GetAccountsDynamic" resultMap="account-result" parameterClass="Hashtable" >
+ select * from Accounts
+ <dynamic prepend="where">
+ <isParameterPresent>
+ <isNotEmpty prepend="and" property="FirstName" >
+ Account_FirstName LIKE '%$FirstName$%'
+ </isNotEmpty>
+ <isNotEmpty prepend="and" property="LastName" >
+ Account_LastName LIKE '%$LastName$%'
+ </isNotEmpty>
+ <isNotEmpty prepend="and" property="EmailAddress" >
+ Account_Email LIKE '%$EmailAddress$%'
+ </isNotEmpty>
+ </isParameterPresent>
+ </dynamic>
+ order by Account_LastName
+ limit 0, $MaximumAllowed$
+ </select>
+
+ <select id="SelectWithProperty"
+ resultMap="account-result">
+ select *
+ from Accounts
+ where Account_FirstName = ${accountName}
+ </select>
+
+ <select id="GetCachedAccountsViaResultMap"
+ resultMap="account-result"
+ cacheModel="account-cache" >
+ select *
+ from Accounts
+ order by Account_Id
+ </select>
+
+ <select id="GetNoAccountWithCache"
+ parameterClass="Integer"
+ resultMap="account-hashtable-result"
+ cacheModel="account-cache">
+ select *
+ from Accounts
+ where Account_Id = #value#
+ </select>
+
+ <select id="GetAccountAsHashtable"
+ parameterClass="Integer"
+ resultMap="account-hashtable-result">
+ select *
+ from Accounts
+ where Account_Id = #value#
+ </select>
+
+ <select id="GetAllAccountsAsHashMapViaResultMap"
+ resultMap="account-hashtable-result">
+ select *
+ from Accounts
+ order by Account_Id
+ </select>
+
+ <select id="GetAccountAsHashtableResultClass"
+ parameterClass="int"
+ resultClass="array">
+ select
+ Account_Id as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ where Account_Id = #value#
+ </select>
+
+ <select id="GetAllAccountsAsHashtableViaResultClass"
+ resultClass="array">
+ select
+ Account_Id as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ order by Account_Id
+ </select>
+
+ <select id="GetAccountViaColumnName"
+ parameterClass="int"
+ resultMap="account-result">
+ select
+ Account_Id,
+ Account_FirstName,
+ Account_LastName,
+ Account_Email,
+ Account_Banner_Option,
+ Account_Cart_Option
+ from Accounts
+ where Account_Id = #value#
+ </select>
+
+ <select id="GetAccountViaColumnIndex"
+ parameterClass="int"
+ resultMap="indexed-account-result">
+ select
+ Account_Id,
+ Account_FirstName,
+ Account_LastName,
+ Account_Email
+ from Accounts
+ where Account_Id = #value#
+ </select>
+
+ <select id="GetAllAccountsViaResultMap"
+ resultMap="account-result">
+ select * from Accounts
+ order by Account_Id
+ </select>
+
+ <select id="GetAllAccountsViaResultClass"
+ resultClass="Account">
+ select
+ Account_Id as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ order by Account_Id
+ </select>
+
+ <select id="GetFewAccountsViaResultMap"
+ resultMap="account-result">
+ <![CDATA[
+ select * from Accounts
+ where Account_Id < 2
+ order by Account_Id
+ ]]>
+ </select>
+
+ <select id="GetNoAccountsViaResultMap"
+ resultMap="account-result">
+ select * from Accounts
+ where Account_Id > 1000
+ order by Account_Id
+ </select>
+
+
+ <select id="GetAccountNullableEmail"
+ resultMap="account-result-nullable-email">
+ select
+ Account_Id,
+ Account_FirstName,
+ Account_LastName,
+ Account_Email
+ from Accounts
+ where Account_Id = #value#
+ </select>
+
+ <select id="GetAccountViaResultClass"
+ resultClass="Account">
+ <![CDATA[
+ select
+ Account_Id as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ where Account_Id = #value#
+ ]]>
+ </select>
+
+ <select id="GetAccountViaInlineParameters"
+ resultMap="indexed-account-result">
+ select
+ Account_Id,
+ Account_FirstName,
+ Account_LastName,
+ Account_Email
+ from Accounts
+ where Account_Id = #Id# and Account_Id = #Id#
+ </select>
+
+ <select id="GetEmailAddressViaResultClass" resultClass="string">
+ select Account_Email as value
+ from Accounts
+ where Account_Id = #value#
+ </select>
+
+ <select id="GetEmailAddressViaResultMap"
+ parameterClass="int"
+ resultMap="email-result">
+ select Account_Email
+ from Accounts
+ where Account_Id = #value#
+ </select>
+
+ <select id="GetAllEmailAddressesViaResultClass"
+ resultClass="string">
+ select Account_Email
+ from Accounts
+ order by Account_Id
+ </select>
+
+ <select id="GetAllEmailAddressesViaResultMap"
+ resultMap="email-result">
+ select Account_Email
+ from Accounts
+ order by Account_Id
+ </select>
+
+ <insert id="InsertAccountViaParameterMap"
+ parameterMap="account-insert-params">
+ insert into Accounts
+ (Account_Id, Account_FirstName, Account_LastName, Account_Email, Account_Banner_Option, Account_Cart_Option)
+ values
+ (?, ?, ?, ?, ?, ?)
+ </insert>
+
+ <update id="UpdateAccountViaParameterMap"
+ parameterMap="update-params">
+ update Accounts set
+ Account_FirstName = ?,
+ Account_LastName = ?,
+ Account_Email = ?
+ where
+ Account_Id = ?
+ </update>
+
+ <update id="UpdateAccountViaParameterMap2"
+ parameterMap="update-params2">
+ update Accounts set
+ Account_Id = ?,
+ Account_FirstName = ?,
+ Account_LastName = ?,
+ Account_Email = ?
+ where
+ Account_Id = ?
+ </update>
+
+ <delete id="DeleteAccountViaInlineParameters">
+ delete from Accounts
+ where
+ Account_Id = #Id#
+ </delete>
+
+ <select id="GetAccountComplexMapping"
+ resultMap="indexed-account-result"
+ parameterClass="array">
+ select *
+ from Accounts
+ where
+ Account_FirstName = #Account.FirstName#
+ And Account_LastName = #Order.City#
+ </select>
+
+ <select id="GetDynamicOrderedEmailAddressesViaResultMap"
+ resultMap="email-result">
+ select Account_Email
+ from Accounts
+ order by $value$
+ </select>
+
+ <!-- Dynamic statements -->
+ <select id="GetAllAccountsViaResultMapWithDynamicElement"
+ resultMap="account-result">
+ select * from Accounts
+ where Account_Email $value$ '%@%'
+ order by Account_Id
+ </select>
+
+ <select id="SimpleDynamicSubstitution"
+ parameterClass="Hashtable"
+ resultClass="Account">
+ $statement$
+ </select>
+
+ <!-- Public Fields -->
+ <insert id="InsertAccountViaPublicFields">
+ insert into Accounts
+ (Account_Id, Account_FirstName, Account_LastName, Account_Email)
+ values
+ (#Id#, #FirstName#, #LastName#, #EmailAddress#
+ )
+ </insert>
+
+
+ <!-- Inline Parameters -->
+ <update id="UpdateAccountViaInlineParameters"
+ parameterClass="Account">
+ update Accounts set
+ Account_FirstName = #FirstName#,
+ Account_LastName = #LastName#,
+ Account_Email = #EmailAddress, dbType=VarChar, nullValue=no_email@provided.com#
+ where
+ Account_Id = #Id#
+ </update>
+
+ <insert id="InsertAccountViaInlineParameters"
+ parameterClass="Account" >
+ insert into Accounts
+ (Account_Id, Account_FirstName, Account_LastName, Account_Email)
+ values
+ (#Id#, #FirstName#, #LastName#, #EmailAddress, dbType=VarChar, nullValue=no_email@provided.com#
+ )
+ </insert>
+
+ <insert id="InsertAccountNullableEmail"
+ parameterClass="Account" >
+ insert into Accounts
+ (Account_Id, Account_FirstName, Account_LastName, Account_Email)
+ values
+ ( #Id#, #FirstName#, #LastName#, #EmailAddress, dbType=VarChar# )
+ </insert>
+
+ <insert id="InsertAccountUknownParameterClass">
+ insert into Accounts
+ (Account_Id, Account_FirstName, Account_LastName, Account_Email)
+ values
+ ( #Id#, #FirstName#, #LastName#, #EmailAddress, dbType=VarChar# )
+ </insert>
+
+ <delete id="DeleteAccount"
+ parameterClass="Account">
+ delete from Accounts
+ where Account_Id = #Id#
+ and Account_Id = #Id#
+ </delete>
+
+ <!-- Extends statement -->
+ <select id="GetAllAccounts"
+ resultMap="indexed-account-result">
+ select
+ Account_Id,
+ Account_FirstName,
+ Account_LastName,
+ Account_Email
+ from Accounts
+ </select>
+
+ <select id="GetAllAccountsOrderByName"
+ extends="GetAllAccounts"
+ resultMap="indexed-account-result">
+ order by Account_FirstName
+ </select>
+
+ <select id="GetOneAccount"
+ extends="GetAllAccounts"
+ resultMap="indexed-account-result">
+ where Account_Id = #value#
+ </select>
+
+ <select id="GetSomeAccount"
+ extends="GetAllAccounts"
+ parameterClass="Hashtable"
+ resultMap="indexed-account-result">
+ where Account_Id between #lowID# and #hightID#
+ </select>
+
+ <select id="SelectAccountJIRA29" parameterClass="map" resultClass="Account">
+ select
+ Account_Id as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ where Account_FirstName = '##$AccountName$##'
+ </select>
+
+ <select id="SelectAccountJIRA29-2"
+ parameterClass="Hashtable"
+ resultClass="Account">
+ select
+ Account_Id as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ where 1=1
+ <isNotEmpty prepend="AND" property="Foo">
+ (Account_FirstName = '##$Foo$##')
+ </isNotEmpty>
+ </select>
+
+ <select id="GetAccountWithRepeatingProperty"
+ parameterClass="Account"
+ resultMap="indexed-account-result">
+ select
+ Account_Id,
+ Account_FirstName,
+ Account_LastName,
+ Account_Email
+ from Accounts
+ where Account_Id = #Id# and
+ Account_Id = #Id# and
+ Account_FirstName = #FirstName# and
+ Account_LastName = #LastName# and
+ Account_Id = #Id#
+ </select>
+
+ <select id="GetAllAccountsViaCustomTypeHandler"
+ resultMap="account-result">
+ select * from Accounts
+ order by Account_Id
+ </select>
+
+ <!-- JIRA-110 -->
+ <select id="GetManyAccound" resultClass="Account">
+ SELECT
+ Account_Id as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ FROM Accounts
+ </select>
+
+ <select id="Get1Account" extends="GetManyAccound" resultClass="Account">WHERE Account_Id=1</select>
+
+ <statement id="GetAccounts" resultMap="account-result">
+ SELECT *
+ FROM
+ Accounts
+ </statement>
+ <!-- JIRA-110 -->
+
+ <insert id="InsertAccountDynamic" parameterClass="Account">
+ INSERT INTO Accounts
+ (Account_Id, Account_FirstName, Account_LastName, Account_Email)
+ VALUES(#Id#, #FirstName#, #LastName#
+ <dynamic prepend=",">
+ <isNotNull prepend="," property="EmailAddress">
+ #EmailAddress#
+ </isNotNull>
+ <isNull prepend="," property="EmailAddress">
+ null
+ </isNull>
+ </dynamic>
+ )
+ </insert>
+
+
+ <!-- accounts and orders -->
+
+ <select id="getAccountWithOrders" resultMap="Account-with-Orders">
+ SELECT
+ Accounts.Account_Id as Account_Id,
+ Accounts.Account_FirstName as Account_FirstName,
+ Accounts.Account_LastName as Account_LastName,
+ Accounts.Account_Email as Account_Email,
+ Accounts.Account_Banner_Option as Account_Banner_Option,
+ Accounts.Account_Cart_Option as Account_Cart_Option,
+ Orders.Order_Id as Order_Id,
+ Orders.Order_Date as Order_Date,
+ Orders.Order_CardType as Order_CardType,
+ Orders.Order_CardNumber as Order_CardNumber,
+ Orders.Order_CardExpiry as Order_CardExpiry,
+ Orders.Order_Street as Order_Street,
+ Orders.Order_City as Order_City,
+ Orders.Order_Province as Order_Province,
+ Orders.Order_PostalCode as Order_PostalCode,
+ Orders.Order_FavouriteLineItem as Order_FavouriteLineItem
+ FROM accounts
+ LEFT JOIN orders ON
+ accounts.account_id = orders.account_id
+ </select>
+
+ <resultMap id="Account-with-Orders" class="AccountWithOrders" groupBy="Account_Id">
+ <result property="Id" column="Account_Id"/>
+ <result property="FirstName" column="Account_FirstName"/>
+ <result property="LastName" column="Account_LastName"/>
+ <result property="EmailAddress" column="Account_Email" />
+ <result property="Orders" resultMapping="account-orders" />
+ </resultMap>
+
+ <resultMap id="account-orders" class="Order">
+ <result property="Id" column="Order_Id"/>
+ <result property="Date" type="date" column="Order_Date" nullValue="0001-01-01 00:00:00"/>
+ <result property="CardExpiry" column="Order_CardExpiry"/>
+ <result property="CardType" column="Order_CardType"/>
+ <result property="CardNumber" column="Order_CardNumber"/>
+ <result property="Street" column="Order_Street"/>
+ <result property="City" column="Order_City"/>
+ <result property="Province" column="Order_Province"/>
+ <result property="PostalCode" column="Order_PostalCode"/>
+ </resultMap>
+
+
+ <!-- For procedure, the parameters of the parameterMap must in the same order
+ as for the procedure paramaters-->
+ <procedure id="InsertAccountViaStoreProcedure" parameterMap="account-insert-params">
+ ps_InsertAccount
+ </procedure>
+
+ <procedure id="SwapEmailAddresses" parameterMap="swap-params">
+ ps_swap_email_address
+ </procedure>
+
+ <!-- =============================================
+ OPTIONAL EXPLICIT PARAMETER MAP
+ ============================================= -->
+
+ <parameterMap id="swap-params">
+ <parameter property="email1" column="First_Email" />
+ <parameter property="email2" column="Second_Email" />
+ </parameterMap>
+
+ <parameterMap id="account-insert-params">
+ <parameter property="Id" />
+ <parameter property="FirstName" />
+ <parameter property="LastName" />
+ <parameter property="EmailAddress" nullValue="no_email@provided.com"/>
+ <parameter property="BannerOptions" dbType="Varchar" type="bool"/>
+ <parameter property="CartOptions" column="Account_Cart_Option" typeHandler="HundredsBool"/>
+ </parameterMap>
+
+ <parameterMap id="update-params">
+ <parameter property="FirstName" />
+ <parameter property="LastName" />
+ <parameter property="EmailAddress" nullValue="no_email@provided.com"/>
+ <parameter property="Id" />
+ </parameterMap>
+
+ <parameterMap id="update-params2">
+ <parameter property="Id" />
+ <parameter property="FirstName" />
+ <parameter property="LastName" />
+ <parameter property="EmailAddress" nullValue="no_email@provided.com"/>
+ <parameter property="Id" />
+ </parameterMap>
+
+
+</sqlMap> \ No newline at end of file
diff --git a/tests/unit/Data/SqlMap/maps/sqlite/ActiveRecord.xml b/tests/unit/Data/SqlMap/maps/sqlite/ActiveRecord.xml
new file mode 100644
index 00000000..1c48010f
--- /dev/null
+++ b/tests/unit/Data/SqlMap/maps/sqlite/ActiveRecord.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<sqlMap>
+
+ <select id="GetActiveRecordAccounts" resultClass="ActiveAccount">
+ select
+ Account_Id,
+ Account_FirstName,
+ Account_LastName,
+ Account_Email,
+ Account_Banner_Option,
+ Account_Cart_Option
+ from Accounts
+ order by Account_Id
+ </select>
+
+</sqlMap> \ No newline at end of file
diff --git a/tests/unit/Data/SqlMap/maps/sqlite/Category.xml b/tests/unit/Data/SqlMap/maps/sqlite/Category.xml
new file mode 100644
index 00000000..05c51fb5
--- /dev/null
+++ b/tests/unit/Data/SqlMap/maps/sqlite/Category.xml
@@ -0,0 +1,162 @@
+<?xml version="1.0" encoding="utf-8"?>
+<sqlMap namespace="Category" >
+
+ <alias>
+ <typeAlias alias="Category" type="IBatisNet.DataMapper.Test.Domain.Category, IBatisNet.DataMapper.Test"/>
+ </alias>
+
+
+ <select id="GetCategory" parameterClass="Integer" resultClass="Category">
+ select
+ Category_ID as Id,
+ Category_Name as Name,
+ Category_Guid as GuidString
+ from Categories
+ where Category_ID = #value#
+ </select>
+
+ <select id="GetCategoryGuid" parameterClass="Integer" resultClass="guid">
+ select
+ Category_Guid as value
+ from Categories
+ where Category_ID = #value#
+ </select>
+
+ <!-- Test for statement as insert -->
+ <!-- Needs to be <insert> vs <statement> for MySql due to selectKey -->
+ <insert id="InsertCategory" parameterClass="Category">
+ <selectKey property="Id" type="post" resultClass="int">
+ select LAST_INSERT_ID() as value
+ </selectKey>
+ insert into Categories
+ (Category_Name, Category_Guid)
+ values
+ (#Name#, #GuidString:Varchar#);
+ </insert>
+
+ <!-- -->
+ <insert id="InsertCategoryViaInsertStatement" parameterClass="Category" >
+ <selectKey property="Id" type="post" resultClass="int">
+ select LAST_INSERT_ID() as value
+ </selectKey>
+ insert into Categories
+ (Category_Name, Category_Guid)
+ values
+ (#Name#, #GuidString:Varchar#)
+ </insert>
+
+ <!-- Needs to be <insert> vs <statement> for MySql due to selectKey -->
+ <insert id="InsertCategoryViaParameterMap" parameterMap="InsertParam">
+ <selectKey property="Id" type="post" resultClass="int">
+ select LAST_INSERT_ID() as value
+ </selectKey>
+ insert into Categories
+ (Category_Name, Category_Guid)
+ values
+ (?,?);
+ </insert>
+
+ <!-- Needs to be <insert> vs <statement> for MySql due to selectKey -->
+ <insert id="InsertCategoryNull" parameterMap="insert-null-params">
+ <selectKey property="Id" type="post" resultClass="int">
+ select LAST_INSERT_ID() as value
+ </selectKey>
+ insert into Categories
+ (Category_Name, Category_Guid)
+ values
+ (?,?);
+ </insert>
+
+ <update id="UpdateCategoryViaParameterMap" parameterMap="UpdateParam">
+ update Categories set
+ Category_Name =?,
+ Category_Guid = ?
+ where
+ Category_Id = ?
+ </update>
+
+ <procedure id="InsertCategoryViaStoreProcedure" parameterMap="category-insert-params">
+ ps_InsertCategorie
+ </procedure>
+
+ <insert id="InsertCategoryGenerate" parameterMap="insert-generate-params">
+ <selectKey property="Id" type="post" resultClass="int">
+ select LAST_INSERT_ID() as value
+ </selectKey>
+ <generate table="Categories" />
+ </insert>
+
+ <update id="UpdateCategoryGenerate" parameterMap="update-generate-params">
+ <generate table="Categories" by="Category_Id"/>
+ </update>
+
+ <delete id="DeleteCategoryGenerate" parameterMap="delete-generate-params">
+ <generate table="Categories" by="Category_Id, Category_Name"/>
+ </delete>
+
+ <select id="SelectByPKCategoryGenerate" resultClass="Category" parameterClass="Category" parameterMap="select-generate-params">
+ <generate table="Categories" by="Category_Id"/>
+ </select>
+
+ <select id="SelectAllCategoryGenerate" resultClass="Category" parameterMap="select-generate-params">
+ <generate table="Categories" />
+ </select>
+
+ <statement id="DynamicGuid"
+ resultClass="Category"
+ parameterClass="Category">
+ select
+ Category_ID as Id,
+ Category_Name as Name,
+ Category_Guid as Guid
+ from Categories
+ <dynamic prepend="where">
+ <isNotEqual prepend="and" property="Guid" compareProperty="EmptyGuid">
+ Category_Guid=#GuidString:Varchar#
+ </isNotEqual>
+ </dynamic>
+ </statement>
+ <parameterMap id="category-insert-params">
+ <parameter property="Id" column="Category_Id" dbType="Int32" />
+ <parameter property="Name" column="Category_Name"/>
+ <parameter property="GuidString" column="Category_Guid" dbType="Varchar"/>
+ </parameterMap>
+
+ <parameterMap id="InsertParam">
+ <parameter property="Name" column="Category_Name"/>
+ <parameter property="GuidString" column="Category_Guid" dbType="Varchar"/>
+ </parameterMap>
+
+ <parameterMap id="insert-null-params">
+ <parameter property="Name" column="Category_Name"/>
+ <parameter property="GuidString" column="Category_Guid" nullValue="00000000-0000-0000-0000-000000000000" dbType="Varchar"/>
+ </parameterMap>
+
+ <parameterMap id="UpdateParam" extends="InsertParam">
+ <parameter property="Id" column="Category_Id" />
+ </parameterMap>
+
+ <!-- Used by generated statement -->
+
+ <parameterMap id="insert-generate-params">
+ <parameter property="Name" column="Category_Name"/>
+ <parameter property="GuidString" column="Category_Guid" dbType="Varchar"/>
+ </parameterMap>
+
+ <parameterMap id="update-generate-params" extends="insert-generate-params">
+ <parameter property="Id" column="Category_Id" />
+ </parameterMap>
+
+ <parameterMap id="delete-generate-params">
+ <parameter property="Id" column="Category_Id" />
+ <parameter property="Name" column="Category_Name"/>
+ </parameterMap>
+
+ <parameterMap id="select-generate-params">
+ <parameter property="Id" column="Category_Id" />
+ <parameter property="Name" column="Category_Name"/>
+ <parameter property="GuidString" column="Category_Guid" dbType="Varchar"/>
+ </parameterMap>
+
+
+</sqlMap>
diff --git a/tests/unit/Data/SqlMap/maps/sqlite/Complex.xml b/tests/unit/Data/SqlMap/maps/sqlite/Complex.xml
new file mode 100644
index 00000000..c596e555
--- /dev/null
+++ b/tests/unit/Data/SqlMap/maps/sqlite/Complex.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<sqlMap namespace="Complex" >
+
+ <statements>
+
+ <statement id="ComplexMap"
+ resultClass="int" >
+ select Account_ID from Accounts where Account_ID = #obj.Map.Id#
+ </statement>
+
+ <insert id="InsertComplexAccountViaInlineDefaultNull"
+ parameterClass="Hashtable" >
+ insert into Accounts
+ (Account_ID, Account_FirstName, Account_LastName, Account_Email)
+ values
+ (#obj.Map.acct.Id#, #obj.Map.acct.FirstName#, #obj.Map.acct.LastName#, #obj.Map.acct.EmailAddress:Varchar:no_email@provided.com#
+ )
+ </insert>
+
+ </statements>
+
+
+</sqlMap>
diff --git a/tests/unit/Data/SqlMap/maps/sqlite/Document.xml b/tests/unit/Data/SqlMap/maps/sqlite/Document.xml
new file mode 100644
index 00000000..83028e05
--- /dev/null
+++ b/tests/unit/Data/SqlMap/maps/sqlite/Document.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<sqlMap namespace="Document" >
+
+ <resultMap id="document" class="Document">
+ <result property="Id" column="Document_Id" type="integer" />
+ <result property="Title" column="Document_Title"/>
+ <discriminator column="Document_Type" type="string"/>
+ <subMap value="Book" resultMapping="book" />
+ <subMap value="Newspaper" resultMapping="newspaper" />
+ </resultMap>
+
+ <resultMap id="document-custom-handler" class="Document">
+ <result property="Id" column="Document_Id" type="integer"/>
+ <result property="Title" column="Document_Title"/>
+ <discriminator column="Document_Type" typeHandler="CustomInheritance"/>
+ <subMap value="Book" resultMapping="book" />
+ <subMap value="Newspaper" resultMapping="newspaper" />
+ </resultMap>
+
+ <resultMap id="book" class="Book" extends="document">
+ <result property="PageNumber" column="Document_PageNumber"/>
+ </resultMap>
+
+ <resultMap id="newspaper" class="Newspaper" extends="document">
+ <result property="City" column="Document_City"/>
+ </resultMap>
+
+ <statement id="GetAllDocument"
+ resultMap="document">
+ select
+ *
+ from Documents
+ order by Document_Type, Document_Id
+ </statement>
+
+ <select id="GetTypedCollection"
+ listClass="DocumentCollection"
+ resultMap="document">
+ select
+ *
+ from Documents
+ order by Document_Type, Document_Id
+ </select>
+
+ <select id="GetAllDocumentWithCustomTypeHandler"
+ resultMap="document-custom-handler">
+ select
+ *
+ from Documents
+ order by Document_Type, Document_Id
+ </select>
+
+</sqlMap> \ No newline at end of file
diff --git a/tests/unit/Data/SqlMap/maps/sqlite/DynamicAccount.xml b/tests/unit/Data/SqlMap/maps/sqlite/DynamicAccount.xml
new file mode 100644
index 00000000..429a745a
--- /dev/null
+++ b/tests/unit/Data/SqlMap/maps/sqlite/DynamicAccount.xml
@@ -0,0 +1,447 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<sqlMap namespace="Account" >
+
+ <alias>
+ <typeAlias alias="Search" type="IBatisNet.DataMapper.Test.Domain.Search, IBatisNet.DataMapper.Test"/>
+ </alias>
+
+ <statements>
+
+ <select id="DynamicAll"
+ parameterClass="Account"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ </select>
+
+ <select id="DynamicWithExtend"
+ extends="DynamicAll"
+ parameterClass="Account"
+ resultClass="Account">
+ <dynamic prepend="WHERE" >
+ <isGreaterThan prepend="AND" property="Id" compareValue="0" >
+ Account_ID = #Id#
+ </isGreaterThan>
+ <isNotNull prepend="AND" property="Ids" >
+ Account_ID in
+ <iterate property="Ids" open="(" close=")" conjunction="," >
+ #Ids[]#
+ </iterate>
+ </isNotNull>
+ <isNotEmpty prepend="AND" property="FirstName" >
+ Account_FirstName = #FirstName#
+ </isNotEmpty>
+ <isNotEmpty prepend="AND" property="LastName" >
+ Account_LastName = #LastName#
+ </isNotEmpty>
+ <isNotEmpty prepend="AND" property="EmailAddress" >
+ <isEqual property="EmailAddress" compareValue="Joe">
+ Account_Email = 'clinton.begin@ibatis.com'
+ </isEqual>
+ <isNotEqual property="EmailAddress" compareValue="Joe">
+ Account_Email = #EmailAddress#
+ </isNotEqual>
+ </isNotEmpty>
+ </dynamic>
+ </select>
+
+ <!-- IBATISNET-114: remapResults -->
+ <statement id="DynamicSqlOnColumnSelection"
+ parameterClass="Account"
+ resultClass="Account">
+ SELECT
+ Account_ID as Id,
+ <dynamic>
+ <isEqual property="LastName" compareValue="Dalton" >
+ Account_FirstName as FirstName,
+ </isEqual>
+ <isEqual property="LastName" compareValue="Dalton" >
+ Account_LastName as LastName,
+ </isEqual>
+ </dynamic>
+
+ Account_Email as EmailAddress
+ FROM
+ Accounts
+ </statement>
+
+ <statement id="DynamicIsEqual"
+ parameterClass="string"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ <isEqual compareValue="Joe" >
+ where Account_FirstName = 'Joe'
+ </isEqual>
+ </statement>
+
+ <statement id="DynamicIsParameterPresent"
+ parameterClass="integer"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ <isParameterPresent >
+ where Account_ID = #value#
+ </isParameterPresent>
+ </statement>
+
+ <statement id="DynamicIsNotEmpty"
+ parameterClass="string"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ <isNotEmpty>
+ where Account_FirstName = #value#
+ </isNotEmpty>
+ </statement>
+
+ <statement id="DynamicIsGreater"
+ parameterClass="int"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ <isGreaterThan compareValue="3" >
+ where Account_ID = 1
+ </isGreaterThan>
+ </statement>
+
+ <statement id="DynamicIsGreaterEqual"
+ parameterClass="int"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ <isGreaterEqual compareValue="3" >
+ where Account_ID = 1
+ </isGreaterEqual>
+ </statement>
+
+ <statement id="DynamicIsLess"
+ parameterClass="int"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ <isLessThan compareValue="3" >
+ where Account_ID = 1
+ </isLessThan>
+ </statement>
+
+ <statement id="DynamicIsLessEqual"
+ parameterClass="int"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ <isLessEqual compareValue="3" >
+ where Account_ID = 1
+ </isLessEqual>
+ </statement>
+
+ <statement id="DynamicIsNotNull"
+ parameterClass="string"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ <isNotNull>
+ where Account_ID = 1
+ </isNotNull>
+ </statement>
+
+ <statement id="DynamicIsPropertyAvailable"
+ parameterClass="string"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ <isPropertyAvailable property="Id" >
+ where Account_ID = 1
+ </isPropertyAvailable>
+ </statement>
+
+
+ <statement id="DynamicSubst"
+ parameterClass="map"
+ resultClass="Account">
+ <dynamic>
+ $statement$
+ </dynamic>
+ </statement>
+
+ <statement id="DynamicIterate"
+ parameterClass="list"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ WHERE Account_ID IN
+ <iterate open="(" close=")" conjunction=",">
+ #[]#
+ </iterate>
+ </statement>
+
+ <statement id="DynamicIterate2"
+ parameterClass="Account"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ WHERE Account_ID IN
+ <iterate property="Ids" open="(" close=")" conjunction="," >
+ #Ids[]#
+ </iterate>
+ </statement>
+
+ <statement id="MultiDynamicIterate"
+ parameterClass="list"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ WHERE Account_ID IN
+ <iterate open="(" close=")" conjunction=",">
+ #[]#
+ </iterate>
+ and Account_ID IN
+ <iterate open="(" close=")" conjunction=",">
+ #[]#
+ </iterate>
+ </statement>
+
+
+ <statement id="DynamicQueryByExample"
+ parameterClass="Account"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ <dynamic prepend="WHERE" >
+ <isGreaterThan prepend="AND" property="Id" compareValue="0" >
+ Account_ID = #Id#
+ </isGreaterThan>
+ <isNotNull prepend="AND" property="Ids" >
+ Account_ID in
+ <iterate property="Ids" open="(" close=")" conjunction="," >
+ #Ids[]#
+ </iterate>
+ </isNotNull>
+ <isNotEmpty prepend="AND" property="FirstName" >
+ Account_FirstName = #FirstName#
+ </isNotEmpty>
+ <isNotEmpty prepend="AND" property="LastName" >
+ Account_LastName = #LastName#
+ </isNotEmpty>
+ <isNotEmpty prepend="AND" property="EmailAddress" >
+ <isEqual property="EmailAddress" compareValue="Joe">
+ Account_Email = 'clinton.begin@ibatis.com'
+ </isEqual>
+ <isNotEqual property="EmailAddress" compareValue="Joe">
+ Account_Email = #EmailAddress#
+ </isNotEqual>
+ </isNotEmpty>
+ </dynamic>
+ </statement>
+
+ <statement id="DynamicIterateWithPrepend1"
+ parameterClass="list"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ <dynamic prepend="where" >
+ Account_ID IN
+ <iterate open="(" close=")" conjunction=",">
+ #[]#
+ </iterate>
+ </dynamic>
+ </statement>
+
+ <statement id="DynamicIterateWithPrepend2"
+ parameterClass="list"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ <dynamic prepend="where" >
+ <iterate open="(" close=")" conjunction="OR">
+ Account_ID = #[]#
+ </iterate>
+ </dynamic>
+ </statement>
+
+ <statement id="DynamicIterateWithPrepend3"
+ parameterClass="list"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ <dynamic prepend="where" >
+ <isParameterPresent prepend="BLAH!" >
+ <iterate open="(" close=")" conjunction="OR">
+ Account_ID = #[]#
+ </iterate>
+ </isParameterPresent>
+ </dynamic>
+ </statement>
+
+ <statement id="DynamicWithPrepend"
+ parameterClass="Account"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ <dynamic prepend="where">
+ <isParameterPresent>
+ <isNotEmpty prepend="and" property="Id" >
+ Account_ID = #Id#
+ </isNotEmpty>
+ <isNotEmpty prepend="and" property="FirstName" >
+ Account_FirstName = #FirstName#
+ </isNotEmpty>
+ <isNotEmpty prepend="and" property="LastName" >
+ Account_LastName = #LastName#
+ </isNotEmpty>
+ </isParameterPresent>
+ </dynamic>
+ </statement>
+
+ <statement id="DynamicWithTwoDynamicElements"
+ parameterClass="Account"
+ resultClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ <dynamic prepend="where">
+ <isNotEmpty prepend="BLAH!" property="Id" >
+ Account_ID = #Id#
+ </isNotEmpty>
+ </dynamic>
+ <dynamic prepend="and">
+ <isNotEmpty prepend="BLAH!" property="FirstName" >
+ Account_FirstName = #FirstName#
+ </isNotEmpty>
+ <isNotEmpty prepend="and" property="LastName" >
+ Account_LastName = #LastName#
+ </isNotEmpty>
+ </dynamic>
+ </statement>
+
+ <statement id="ComplexDynamicStatement"
+ cacheModel="account-cache"
+ resultClass="Account"
+ parameterClass="Account">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ <dynamic prepend="WHERE">
+ <isNotNull prepend="AND" property="FirstName">
+ (Account_FirstName = #FirstName#
+ <isNotNull prepend="OR" property="LastName">
+ Account_LastName = #LastName#
+ </isNotNull>
+ )
+ </isNotNull>
+ <isNotNull prepend="AND" property="EmailAddress">
+ Account_Email like #EmailAddress#
+ </isNotNull>
+ <isGreaterThan prepend="AND" property="Id" compareValue="0">
+ Account_ID = #Id#
+ </isGreaterThan>
+ </dynamic>
+ order by Account_LastName
+ </statement>
+
+ <statement id="Jira-IBATISNET-11"
+ resultClass="Account"
+ parameterClass="Search">
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+ from Accounts
+ <dynamic prepend="where">
+ <isNotNull prepend="and" property="NumberSearch">
+ ((Account_ID $Operande$ #NumberSearch#) or
+ (Account_ID $Operande$ #NumberSearch#))
+ </isNotNull>
+ <isEqual prepend="and" property="StartDate" compareValue="25/12/2004">
+ <![CDATA[Account_FirstName >= #StartDate# ]]>
+ </isEqual>
+ <isEqual prepend="and" property="StartDateAnd" compareValue="true">
+ <![CDATA[Account_LastName >= #StartDate# ]]>
+ </isEqual>
+ </dynamic>
+
+ order by Account_LastName
+ </statement>
+ </statements>
+
+
+</sqlMap> \ No newline at end of file
diff --git a/tests/unit/Data/SqlMap/maps/sqlite/Enumeration.xml b/tests/unit/Data/SqlMap/maps/sqlite/Enumeration.xml
new file mode 100644
index 00000000..58391c5d
--- /dev/null
+++ b/tests/unit/Data/SqlMap/maps/sqlite/Enumeration.xml
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="utf-8"?>
+<sqlMap namespace="Enumeration" >
+
+ <resultMaps>
+ <resultMap id="enumeration-result" class="Enumeration" >
+ <result property="Id" column="Enum_ID"/>
+ <result property="Day" column="Enum_Day"/>
+ <result property="Color" column="Enum_Color"/>
+ <result property="Month" column="Enum_Month" nullValue="All"/>
+ </resultMap>
+ </resultMaps>
+
+ <statements>
+
+ <select id="GetEnumerationNullValue"
+ parameterClass="Integer"
+ resultMap="enumeration-result">
+ select
+ Enum_ID,
+ Enum_Day,
+ Enum_Color,
+ Enum_Month
+ from Enumerations
+ where Enum_ID = #value#
+ </select>
+
+ <select id="GetEnumeration" parameterClass="Integer" resultClass="Enumeration">
+ select
+ Enum_ID as Id,
+ Enum_Day as Day,
+ Enum_Color as Color,
+ Enum_Month as Month
+ from Enumerations
+ where Enum_ID = #value#
+ </select>
+
+ <insert id="InsertEnumViaParameterMap" parameterMap="insert-params" >
+ insert into Enumerations
+ (Enum_ID, Enum_Day, Enum_Color, Enum_Month)
+ values
+ (?, ?, ?, ?)
+ </insert>
+
+ </statements>
+
+ <parameterMaps>
+ <parameterMap id="insert-params">
+ <parameter property="Id" column="Enum_ID" />
+ <parameter property="Day" column="Enum_Day"/>
+ <parameter property="Color" column="Enum_Color" />
+ <parameter property="Month" column="Enum_Month" nullValue="All"/>
+ </parameterMap>
+ </parameterMaps>
+
+</sqlMap>
diff --git a/tests/unit/Data/SqlMap/maps/sqlite/LineItem.xml b/tests/unit/Data/SqlMap/maps/sqlite/LineItem.xml
new file mode 100644
index 00000000..95cc4af7
--- /dev/null
+++ b/tests/unit/Data/SqlMap/maps/sqlite/LineItem.xml
@@ -0,0 +1,183 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<sqlMap namespace="LineItem" >
+
+ <resultMap id="LineItem-Price" class="float">
+ <result property="value" column="LineItem_Price"/>
+ </resultMap>
+
+ <resultMap id="LineItem" class="LineItem">
+ <result property="Id" column="LineItem_Id"/>
+ <result property="Code" column="LineItem_Code"/>
+ <result property="Quantity" column="LineItem_Quantity"/>
+ <result property="Price" column="LineItem_Price"/>
+ </resultMap>
+
+ <resultMap id="LineItemWithNullReplacement" class="LineItem">
+ <result property="Id" column="LineItem_Id"/>
+ <result property="Code" column="LineItem_Code"/>
+ <result property="Quantity" column="LineItem_Quantity"/>
+ <result property="Price" column="LineItem_Price" nullValue="-77.77"/>
+ </resultMap>
+
+
+ <statement id="GetLineItemPrice"
+ parameterClass="array"
+ resultMap="LineItem-Price" >
+ select
+ LineItem_Price
+ from LineItems
+ where Order_ID = #Order_ID#
+ and LineItem_ID = #LineItem_ID#
+ </statement>
+
+ <statement id="GetLineItemsForOrder"
+ parameterClass="int"
+ listClass="TList"
+ resultClass="LineItem">
+ select
+ LineItem_ID as Id,
+ LineItem_Code as Code,
+ LineItem_Quantity as Quantity,
+ LineItem_Price as Price
+ from LineItems where Order_ID = #value#
+ </statement>
+
+
+ <statement id="GetLineItemsForOrderWithListClass"
+ parameterClass="int"
+ listClass="LineItemCollection"
+ resultClass="LineItem">
+ select
+ LineItem_ID as Id,
+ LineItem_Code as Code,
+ LineItem_Quantity as Quantity,
+ LineItem_Price as Price
+ from LineItems where Order_ID = #value#
+ order by LineItem_Code
+ </statement>
+
+ <statement id="GetSpecificLineItem"
+ parameterClass="array"
+ resultClass="LineItem">
+ select
+ LineItem_ID as Id,
+ LineItem_Code as Code,
+ LineItem_Quantity as Quantity,
+ LineItem_Price as Price
+ from LineItems
+ where Order_ID = #Order_ID#
+ and LineItem_ID = #LineItem_ID#
+ </statement>
+
+ <statement id="GetSpecificLineItemWithPicture"
+ parameterClass="array"
+ resultClass="LineItem">
+ select
+ LineItem_ID as Id,
+ LineItem_Code as Code,
+ LineItem_Quantity as Quantity,
+ LineItem_Price as Price,
+ LineItem_Picture as PictureData
+ from LineItems
+ where Order_ID = #Order_ID#
+ and LineItem_ID = #LineItem_ID#
+ </statement>
+
+ <select id="GetDynSpecificLineItem"
+ parameterClass="array"
+ resultClass="LineItem">
+ select
+ LineItem_ID as Id,
+ LineItem_Code as Code,
+ LineItem_Quantity as Quantity,
+ LineItem_Price as Price
+ from LineItems
+ where Order_ID = #Order_ID#
+ <dynamic>
+ <isNotNull property="LineItem_ID">
+ and LineItem_ID = #LineItem_ID#
+ </isNotNull>
+ </dynamic>
+ </select>
+
+ <statement id="GetSpecificLineItemWithNullReplacement"
+ parameterClass="int"
+ resultMap="LineItemWithNullReplacement">
+ select
+ LineItem_ID,
+ LineItem_Code,
+ LineItem_Quantity,
+ LineItem_Price
+ from LineItems
+ where LineItem_ID = #value#
+ </statement>
+
+ <statement id="InsertLineItem"
+ parameterMap="line-item-insert-params" >
+ insert into LineItems
+ (LineItem_ID, Order_ID, LineItem_Code, LineItem_Quantity, LineItem_Price)
+ values
+ (?, ?, ?, ?, ?);
+ </statement>
+
+ <statement id="InsertLineItemWithPicture"
+ parameterMap="line-item-insert-params-picture" >
+ insert into LineItems
+ (LineItem_ID, Order_ID, LineItem_Code, LineItem_Quantity, LineItem_Price, LineItem_Picture)
+ values
+ (?, ?, ?, ?, ?, ?);
+ </statement>
+
+ <insert id="InsertLineItemPostKey" parameterClass="LineItem">
+ insert into LineItems
+ (LineItem_ID, Order_ID, LineItem_Code, LineItem_Quantity, LineItem_Price)
+ values
+ (#Id#, #Order.Id#, #Code#, #Quantity#, #Price, type=float#)
+ <selectKey property="Id" type="post" resultClass="int" >
+ select 99 from LineItems where LineItem_ID = 1 and Order_ID=1
+ </selectKey>
+ </insert>
+
+ <insert id="InsertLineItemPreKey" parameterClass="LineItem">
+ <selectKey property="Id" type="pre" resultClass="int" >
+ select 99 from LineItems where LineItem_ID = 1 and Order_ID=1
+ </selectKey>
+ insert into LineItems
+ (LineItem_ID, Order_ID, LineItem_Code, LineItem_Quantity, LineItem_Price)
+ values
+ (#Id#, #Order.Id#, #Code#, #Quantity#, #Price, type=float#)
+ </insert>
+
+ <insert id="InsertLineItemNoKey" parameterClass="LineItem">
+ insert into LineItems
+ (LineItem_ID, Order_ID, LineItem_Code, LineItem_Quantity, LineItem_Price)
+ values
+ (#Id#, #Order.Id#, #Code#, #Quantity#, #Price, type=float#)
+ </insert>
+
+ <!-- JIRA 23 -->
+ <delete id="DeleteWithComments" >
+ <!-- Delete LineItems -->
+ delete from LineItems where Order_ID = 10;
+ <!-- Delete LineItems -->
+ </delete>
+
+ <parameterMap id="line-item-insert-params">
+ <parameter property="Id" />
+ <parameter property="Order.Id" />
+ <parameter property="Code" />
+ <parameter property="Quantity" />
+ <parameter property="Price" dbType="Decimal" nullValue="-99.99"/>
+ </parameterMap>
+
+ <parameterMap id="line-item-insert-params-picture">
+ <parameter property="Id" />
+ <parameter property="Order.Id" />
+ <parameter property="Code" />
+ <parameter property="Quantity" />
+ <parameter property="Price" dbType="Decimal" nullValue="-99.99"/>
+ <parameter property="PictureData" dbType="Blob" />
+ </parameterMap>
+
+</sqlMap> \ No newline at end of file
diff --git a/tests/unit/Data/SqlMap/maps/sqlite/Order.xml b/tests/unit/Data/SqlMap/maps/sqlite/Order.xml
new file mode 100644
index 00000000..17b45d35
--- /dev/null
+++ b/tests/unit/Data/SqlMap/maps/sqlite/Order.xml
@@ -0,0 +1,503 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<sqlMap namespace="Order">
+
+ <!-- If the type is not specified, ADO.NET infers the
+ data provider Type of the Parameter from the Value property
+ of the Parameter object. -->
+
+
+ <resultMap id="credit-card-result" class="string">
+ <result property="value" column="Order_CardNumber"/>
+ </resultMap>
+ <!-- -->
+ <resultMap id="order-with-lines-result" class="Order"
+ extends="lite-order-result-by-name" >
+ <result property="LineItemsList" lazyLoad="true" type="TList" column="Order_Id" select="GetLineItemsForOrder" />
+ </resultMap>
+
+ <resultMap id="order-with-lines-result-no-lazy-load" class="Order"
+ extends="lite-order-result-by-name" >
+ <result property="LineItemsList" type="TList" column="Order_Id" select="GetLineItemsForOrder" />
+ </resultMap>
+
+ <resultMap id="order-with-lines-result-statement-namespaces" class="Order"
+ extends="lite-order-result-by-name" >
+ <result property="LineItemsList" lazyLoad="true" type="TList" column="Order_Id" select="LineItem.GetLineItemsForOrder" />
+ </resultMap>
+
+ <resultMap id="order-with-lines-collection" class="Order"
+ extends="lite-order-result-by-name" >
+ <result property="LineItems" column="Order_Id" lazyLoad="true"
+ select="GetLineItemsForOrderWithListClass" />
+ </resultMap>
+
+ <resultMap id="order-with-lines-collection-no-lazy-load" class="Order"
+ extends="lite-order-result-by-name" >
+ <result property="LineItems" column="Order_Id"
+ select="GetLineItemsForOrderWithListClass" />
+ </resultMap>
+
+ <resultMap id="order-with-lines-array" class="Order"
+ extends="lite-order-result-by-name">
+ <result property="LineItemsArray" column="Order_Id" select="GetLineItemsForOrder"/>
+ </resultMap>
+
+ <resultMap id="lite-order-map-result" class="array">
+ <result property="Id" type="Int" column="Order_Id"/>
+ <result property="Date" type="date" column="Order_Date"/>
+ <result property="CardExpiry" type="string" column="Order_CardExpiry"/>
+ <result property="CardType" type="string" column="Order_CardType"/>
+ <result property="CardNumber" type="string" column="Order_CardNumber"/>
+ <result property="Street" type="string" column="Order_Street"/>
+ <result property="City" type="string" column="Order_City"/>
+ <result property="Province" type="string" column="Order_Province"/>
+ <result property="PostalCode" type="string" column="Order_PostalCode"/>
+ </resultMap>
+
+ <resultMap id="lite-order-result-by-name" class="Order">
+ <result property="Id" column="Order_Id"/>
+ <result property="Date" type="date" column="Order_Date" nullValue="0001-01-01 00:00:00"/>
+ <result property="CardExpiry" column="Order_CardExpiry"/>
+ <result property="CardType" column="Order_CardType"/>
+ <result property="CardNumber" column="Order_CardNumber"/>
+ <result property="Street" column="Order_Street"/>
+ <result property="City" column="Order_City"/>
+ <result property="Province" column="Order_Province"/>
+ <result property="PostalCode" column="Order_PostalCode"/>
+ </resultMap>
+
+ <resultMap id="order-hash" class="array">
+ <result property="Date" column="Order_Date" nullValue="0001-01-01 00:00:00"/>
+ </resultMap>
+
+ <resultMap id="order-with-types-result" class="Order">
+ <result property="Id" column="Order_Id" />
+ <result property="Date" column="Order_Date" type="date" />
+ <result property="CardExpiry" column="Order_CardExpiry" />
+ <result property="CardType" column="Order_CardType" />
+ <result property="CardNumber" column="Order_CardNumber" />
+ <result property="Street" column="Order_Street" />
+ <result property="City" column="Order_City" />
+ <result property="Province" column="Order_Province" />
+ <result property="PostalCode" column="Order_PostalCode" />
+ </resultMap>
+
+ <resultMap id="lite-order-result-by-index" class="Order">
+ <result property="Id" column="Order_Id" columnIndex="0"/>
+ <result property="Date" column="Order_Date" type="date" columnIndex="1" />
+ <result property="CardExpiry" column="Order_CardExpiry" columnIndex="2"/>
+ <result property="CardType" column="Order_CardType" columnIndex="3" />
+ <result property="CardNumber" column="Order_CardNumber" columnIndex="4" />
+ <result property="Street" column="Order_Street" columnIndex="5" />
+ <result property="City" column="Order_City" columnIndex="6" />
+ <result property="Province" column="Order_Province" columnIndex="7"/>
+ <result property="PostalCode" column="Order_PostalCode" columnIndex="8" />
+ </resultMap>
+
+ <resultMap id="order-with-account-result" class="Order">
+ <result property="Id" column="Order_Id"/>
+ <result property="Date" type="date" column="Order_Date"/>
+ <result property="CardExpiry" column="Order_CardExpiry"/>
+ <result property="CardType" column="Order_CardType"/>
+ <result property="CardNumber" column="Order_CardNumber"/>
+ <result property="Street" column="Order_Street"/>
+ <result property="City" column="Order_City"/>
+ <result property="Province" column="Order_Province"/>
+ <result property="PostalCode" column="Order_PostalCode"/>
+ <result property="Account" column="Account_Id" select="GetAccountViaColumnName" />
+ </resultMap>
+
+ <resultMap id="order-with-collection-result" class="Order">
+ <result property="Id" column="Order_Id"/>
+ <result property="Date" type="date" column="Order_Date"/>
+ <result property="CardExpiry" column="Order_CardExpiry"/>
+ <result property="CardType" column="Order_CardType"/>
+ <result property="CardNumber" column="Order_CardNumber"/>
+ <result property="Street" column="Order_Street"/>
+ <result property="City" column="Order_City"/>
+ <result property="Province" column="Order_Province"/>
+ <result property="PostalCode" column="Order_PostalCode"/>
+ <result property="LineItemsList" column="Order_Id" select="GetLineItemsForOrder" />
+ <result property="LineItems" column="Order_Id" select="GetLineItemsForOrder" lazyLoad="false" />
+ </resultMap>
+
+ <resultMap id="order-with-favourite-line-item" class="Order">
+ <result property="Id" column="Order_Id"/>
+ <result property="Date" column="Order_Date"/>
+ <result property="CardExpiry" column="Order_CardExpiry"/>
+ <result property="CardType" column="Order_CardType"/>
+ <result property="CardNumber" column="Order_CardNumber"/>
+ <result property="Street" column="Order_Street"/>
+ <result property="City" column="Order_City"/>
+ <result property="Province" column="Order_Province"/>
+ <result property="PostalCode" column="Order_PostalCode"/>
+ <result property="FavouriteLineItem"
+ column="Order_ID=Order_Id,LineItem_ID=Order_FavouriteLineItem"
+ select="GetSpecificLineItem" />
+ </resultMap>
+
+ <resultMap id="order-with-dyn-favourite-line-item" class="Order">
+ <result property="Id" column="Order_Id"/>
+ <result property="Date" column="Order_Date"/>
+ <result property="CardExpiry" column="Order_CardExpiry"/>
+ <result property="CardType" column="Order_CardType"/>
+ <result property="CardNumber" column="Order_CardNumber"/>
+ <result property="Street" column="Order_Street"/>
+ <result property="City" column="Order_City"/>
+ <result property="Province" column="Order_Province"/>
+ <result property="PostalCode" column="Order_PostalCode"/>
+ <result property="FavouriteLineItem"
+ column="Order_ID=Order_Id,LineItem_ID=Order_FavouriteLineItem"
+ select="GetDynSpecificLineItem" />
+ </resultMap>
+
+ <resultMap id="order-joined-favourite" class="Order">
+ <result property="Id" column="Order_Id"/>
+ <result property="Date" type="date" column="Order_Date"/>
+ <result property="CardExpiry" column="Order_CardExpiry"/>
+ <result property="CardType" column="Order_CardType"/>
+ <result property="CardNumber" column="Order_CardNumber"/>
+ <result property="Street" column="Order_Street"/>
+ <result property="City" column="Order_City"/>
+ <result property="Province" column="Order_Province"/>
+ <result property="PostalCode" column="Order_PostalCode"/>
+ <result property="FavouriteLineItem" resultMapping="LineItem" />
+ </resultMap>
+
+ <resultMap id="order-joined-favourite2" class="Order">
+ <result property="Id" column="Order_Id"/>
+ <result property="Date" type="date" column="Order_Date"/>
+ <result property="CardExpiry" column="Order_CardExpiry"/>
+ <result property="CardType" column="Order_CardType"/>
+ <result property="CardNumber" column="Order_CardNumber"/>
+ <result property="Street" column="Order_Street"/>
+ <result property="City" column="Order_City"/>
+ <result property="Province" column="Order_Province"/>
+ <result property="PostalCode" column="Order_PostalCode"/>
+ <result property="FavouriteLineItem.Id" column="LineItem_Id"/>
+ <result property="FavouriteLineItem.Code" column="LineItem_Code"/>
+ <result property="FavouriteLineItem.Quantity" column="LineItem_Quantity"/>
+ <result property="FavouriteLineItem.Price" column="LineItem_Price"/>
+ </resultMap>
+
+ <resultMap id="order-joined-with-account" class="Order">
+ <result property="Id" column="Order_Id"/>
+ <result property="Date" type="date" column="Order_Date" nullValue="01/01/0001 00:00:00"/>
+ <result property="CardExpiry" column="Order_CardExpiry"/>
+ <result property="CardType" column="Order_CardType"/>
+ <result property="CardNumber" column="Order_CardNumber"/>
+ <result property="Street" column="Order_Street"/>
+ <result property="City" column="Order_City"/>
+ <result property="Province" column="Order_Province"/>
+ <result property="PostalCode" column="Order_PostalCode"/>
+ <result property="Account" resultMapping="account-result-nullable-email" />
+ </resultMap>
+
+ <statement id="GetOrderLiteByColumnName"
+ parameterClass="integer"
+ resultMap="lite-order-result-by-name" >
+ select * from Orders where Order_Id = #value#
+ </statement>
+
+ <statement id="GetOrderByHashTable"
+ parameterClass="Int"
+ resultMap="order-hash" >
+ select Order_Date from Orders where Order_Id = #value#
+ </statement>
+
+ <statement id="GetOrderLiteByColumnIndex"
+ parameterClass="Int"
+ resultMap="lite-order-result-by-index" >
+ select
+ Order_Id,
+ Order_Date,
+ Order_CardExpiry,
+ Order_CardType,
+ Order_CardNumber,
+ Order_Street,
+ Order_City,
+ Order_Province,
+ Order_PostalCode
+ from Orders where Order_Id = #value#
+ </statement>
+
+ <statement id="GetOrderWithTypes"
+ parameterClass="Int"
+ resultMap="order-with-types-result" >
+ select * from Orders where Order_Id = #value#
+ </statement>
+
+ <statement id="GetOrderWithLineItems"
+ parameterClass="Integer"
+ ListClass="TList"
+ resultMap="order-with-lines-result" >
+ select * from Orders where Order_Id = #value#
+ </statement>
+
+
+ <statement id="GetOrderWithLineItemsNoLazyLoad"
+ parameterClass="Integer"
+ resultMap="order-with-lines-result-no-lazy-load" >
+ select * from Orders where Order_Id = #value#
+ </statement>
+
+ <statement id="GetOrderWithLineItemsUsingStatementNamespaces"
+ parameterClass="Integer"
+ resultMap="order-with-lines-result-statement-namespaces" >
+ select * from Orders where Order_Id = #value#
+ </statement>
+
+ <statement id="GetAllOrderWithLineItems"
+ resultMap="order-with-lines-result" >
+ select * from Orders
+ </statement>
+
+ <statement id="GetOrderCardExpiryViaResultClass"
+ parameterClass="int"
+ resultClass="date">
+ select
+ Order_Date as 'datetime'
+ from Orders where Order_Id = #value#
+ </statement>
+
+ <statement id="GetOrderWithAccount"
+ parameterClass="int"
+ resultMap="order-with-account-result" >
+ select * from Orders where Order_Id = #value#
+ </statement>
+
+ <statement id="GetOrderWithLineItemsCollection"
+ parameterClass="Integer"
+ resultMap="order-with-collection-result" >
+ select * from Orders where Order_Id = #value#
+ </statement>
+
+ <statement id="GetOrderJoinedFavourite"
+ parameterClass="Integer"
+ resultMap="order-joined-favourite" >
+ select
+ Orders.Order_Id as Order_Id,
+ Orders.Account_Id as Account_Id,
+ Orders.Order_Date as Order_Date,
+ Orders.Order_CardType as Order_CardType,
+ Orders.Order_CardNumber as Order_CardNumber,
+ Orders.Order_CardExpiry as Order_CardExpiry,
+ Orders.Order_Street as Order_Street,
+ Orders.Order_City as Order_City,
+ Orders.Order_Province as Order_Province,
+ Orders.Order_PostalCode as Order_PostalCode,
+ Orders.Order_FavouriteLineItem as Order_FavouriteLineItem,
+ LineItems.LineItem_Id as LineItem_Id,
+ LineItems.Order_Id as Order_Id,
+ LineItems.LineItem_Code as LineItem_Code,
+ LineItems.LineItem_Quantity as LineItem_Quantity,
+ LineItems.LineItem_Price as LineItem_Price,
+ LineItems.LineItem_Picture as LineItem_Picture
+
+ from Orders, LineItems
+ where Orders.Order_Id = LineItems.Order_Id
+ and Order_FavouriteLineItem = LineItems.LineItem_ID
+ and Orders.Order_Id = #value#
+ </statement>
+
+ <statement id="GetOrderJoinedFavourite2"
+ parameterClass="Integer"
+ resultMap="order-joined-favourite2" >
+ select
+
+ Orders.Order_Id as Order_Id,
+ Orders.Account_Id as Account_Id,
+ Orders.Order_Date as Order_Date,
+ Orders.Order_CardType as Order_CardType,
+ Orders.Order_CardNumber as Order_CardNumber,
+ Orders.Order_CardExpiry as Order_CardExpiry,
+ Orders.Order_Street as Order_Street,
+ Orders.Order_City as Order_City,
+ Orders.Order_Province as Order_Province,
+ Orders.Order_PostalCode as Order_PostalCode,
+ Orders.Order_FavouriteLineItem as Order_FavouriteLineItem,
+ LineItems.LineItem_Id as LineItem_Id,
+ LineItems.Order_Id as Order_Id,
+ LineItems.LineItem_Code as LineItem_Code,
+ LineItems.LineItem_Quantity as LineItem_Quantity,
+ LineItems.LineItem_Price as LineItem_Price,
+ LineItems.LineItem_Picture as LineItem_Picture
+
+ from Orders, LineItems
+ where Orders.Order_Id = LineItems.Order_Id
+ and Order_FavouriteLineItem = LineItems.LineItem_ID
+ and Orders.Order_Id = #value#
+ </statement>
+
+ <statement id="GetOrderJoinedFavourite3"
+ parameterClass="Integer"
+ resultClass="Order" >
+ select
+ Orders.Order_Id as Id,
+ Order_Date as Date,
+ Order_CardExpiry as CardExpiry,
+ Order_CardType as CardType,
+ Order_CardNumber as CardNumber,
+ Order_Street as Street,
+ Order_City as City,
+ Order_Province as Province,
+ Order_PostalCode as PostalCode,
+ LineItem_ID as "FavouriteLineItem.Id",
+ LineItem_Code as "FavouriteLineItem.Code",
+ LineItem_Quantity as "FavouriteLineItem.Quantity",
+ LineItem_Price as "FavouriteLineItem.Price"
+ from Orders, LineItems
+ where Orders.Order_Id = LineItems.Order_Id
+ and Order_FavouriteLineItem = LineItems.LineItem_ID
+ and Orders.Order_Id = #value#
+ </statement>
+
+ <statement id="GetOrderWithFavouriteLineItem"
+ parameterClass="int"
+ resultMap="order-with-favourite-line-item" >
+ select * from Orders where Order_Id = #value#
+ </statement>
+
+ <statement id="GetOrderWithLineItemCollection"
+ parameterClass="int"
+ resultMap="order-with-lines-collection" >
+ select * from Orders where Order_Id = #value#
+ </statement>
+
+ <statement id="GetOrderWithLineItemCollectionNoLazy"
+ parameterClass="int"
+ resultMap="order-with-lines-collection-no-lazy-load" >
+ select * from Orders where Order_Id = #value#
+ </statement>
+
+ <statement id="GetOrderAsHastable"
+ parameterClass="Integer"
+ resultMap="lite-order-map-result" >
+ select * from Orders where Order_Id = #value#
+ </statement>
+
+ <statement id="GetOrderWithLineItemArray"
+ parameterClass="int"
+ resultMap="order-with-lines-array">
+ select * from Orders where Order_Id = #value#
+ </statement>
+
+ <statement id="GetAllCreditCardNumbersFromOrders"
+ resultMap="credit-card-result" >
+ select distinct Order_CardNumber from Orders
+ order by Order_CardNumber
+ </statement>
+
+ <statement id="InsertOrderViaParameterMap"
+ parameterMap="order-insert-params-full" >
+ insert into Orders
+ (Order_Id, Account_ID, Order_Date, Order_CardExpiry, Order_CardType,
+ Order_CardNumber, Order_Street, Order_City, Order_Province, Order_PostalCode )
+ values
+ (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
+ </statement>
+
+ <statement id="InsertOrderViaExtendParameterMap"
+ parameterMap="insert-extend" >
+ insert into Orders
+ (Order_Id, Account_ID, Order_Date, Order_CardExpiry, Order_CardType,
+ Order_CardNumber, Order_Street, Order_City, Order_Province, Order_PostalCode )
+ values
+ (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
+ </statement>
+
+ <statement id="InsertOrderViaPublicFields">
+ insert into Orders
+ (Order_Id, Account_ID, Order_Date, Order_CardExpiry, Order_CardType,
+ Order_CardNumber, Order_Street, Order_City, Order_Province, Order_PostalCode )
+ values
+ (#Id#, #Account.Id#, #Date#, #CardExpiry#, #CardType#, #CardNumber#, #Street#, #City#, #Province#, #PostalCode#)
+ </statement>
+
+ <select id="GetOrderWithDynFavouriteLineItem"
+ parameterClass="Integer"
+ resultMap="order-with-dyn-favourite-line-item">
+ select * from Orders where Order_Id = #value#
+ </select>
+
+ <select id="SelectOrderByDate"
+ parameterClass="array"
+ resultMap="lite-order-result-by-name">
+ select * from Orders where Order_Date = #Foo#
+ </select>
+
+ <select id="SelectOrderByDateDynamic"
+ parameterClass="array"
+ resultMap="lite-order-result-by-name">
+ select * from Orders
+ where 1=1
+ <isNotEmpty prepend="AND" property="Foo">
+ (Order_Date = '$Foo$')
+ </isNotEmpty>
+ </select>
+
+ <select id="GetAccountJIRA45"
+ parameterClass="int"
+ resultMap="indexed-account-result">
+ select
+ Account_Id,
+ Account_FirstName,
+ Account_LastName,
+ Account_Email
+ from Accounts
+ where Account_ID = #value#
+ </select>
+
+ <select id="GetOrderJoinWithAccount"
+ parameterClass="Integer"
+ resultMap="order-joined-with-account">
+ select
+ Order_Id,
+ Order_Date,
+ Order_CardExpiry,
+ Order_CardType,
+ Order_CardNumber,
+ Order_Street,
+ Order_City,
+ Order_Province,
+ Order_PostalCode,
+ acc.Account_ID as Account_ID,
+ acc.Account_FirstName as Account_FirstName,
+ acc.Account_LastName as Account_LastName,
+ acc.Account_Email as Account_Email
+ from Orders as ord
+ LEFT OUTER JOIN Accounts as acc on acc.Account_ID = ord.Account_ID
+ where Order_Id = #value#
+ </select>
+
+ <parameterMap id="order-insert-params-full">
+ <parameter property="Id" dbType="Int32"/>
+ <parameter property="Account.Id"/>
+ <parameter property="Date" nullValue="0001-01-01 00:00:00" />
+ <parameter property="CardExpiry" />
+ <parameter property="CardType" />
+ <parameter property="CardNumber" />
+ <parameter property="Street" />
+ <parameter property="City" />
+ <parameter property="Province" />
+ <parameter property="PostalCode" />
+ </parameterMap>
+
+ <parameterMap id="params-parent"> <!-- 1043181 support request -->
+ <parameter property="Id" dbType="Int32"/>
+ <parameter property="Account.Id"/>
+ <parameter property="Date" nullValue="0001-01-01 00:00:00" />
+ <parameter property="CardExpiry" />
+ <parameter property="CardType" />
+ <parameter property="CardNumber" />
+ <parameter property="Street" />
+ <parameter property="City" />
+ <parameter property="Province" />
+ <parameter property="PostalCode" />
+ </parameterMap>
+
+ <parameterMap id="insert-extend" extends="params-parent">
+ </parameterMap>
+
+</sqlMap> \ No newline at end of file
diff --git a/tests/unit/Data/SqlMap/maps/sqlite/Other.xml b/tests/unit/Data/SqlMap/maps/sqlite/Other.xml
new file mode 100644
index 00000000..f8683f7e
--- /dev/null
+++ b/tests/unit/Data/SqlMap/maps/sqlite/Other.xml
@@ -0,0 +1,170 @@
+<?xml version="1.0" encoding="utf-8"?>
+<sqlMap namespace="Other" >
+
+ <resultMap id="other-result" class="Other" >
+ <result property="Int" column="Other_Int"/>
+ <result property="Long" column="Other_Long"/>
+ <result property="Bool" column="Other_Bit"/>
+ <result property="Bool2" column="Other_String" typeHandler="OuiNonBool"/>
+ </resultMap>
+
+ <resultMap id="other-result-V1" class="Other" >
+ <result property="Int" column="Other_Int"/>
+ <result property="Long" column="Other_Long"/>
+ <result property="Bool" column="Other_Bit"/>
+ <result property="Bool2" column="Other_String" />
+ </resultMap>
+
+ <resultMap id="A-result" class="A" >
+ <result property="Id" column="A_ID"/>
+ <result property="Libelle" column="A_Libelle"/>
+ <result property="B" resultMapping="B-result"/>
+ <result property="E" resultMapping="E-result"/>
+ <result property="F" resultMapping="F-result"/>
+ </resultMap>
+
+ <resultMap id="B-result" class="B" >
+ <result property="Id" column="B_ID"/>
+ <result property="Libelle" column="B_Libelle"/>
+ <result property="C" resultMapping="C-result"/>
+ <result property="D" resultMapping="D-result"/>
+ </resultMap>
+
+ <resultMap id="C-result" class="C" >
+ <result property="Id" column="C_ID"/>
+ <result property="Libelle" column="C_Libelle"/>
+ </resultMap>
+
+ <resultMap id="D-result" class="D" >
+ <result property="Id" column="D_ID"/>
+ <result property="Libelle" column="D_Libelle"/>
+ </resultMap>
+
+ <resultMap id="E-result" class="E" >
+ <result property="Id" column="E_ID"/>
+ <result property="Libelle" column="E_Libelle"/>
+ </resultMap>
+
+ <resultMap id="F-result" class="F" >
+ <result property="Id" column="F_ID"/>
+ <result property="Libelle" column="F_Libelle"/>
+ </resultMap>
+
+ <select id="SelectComplexJoined" resultMap="A-result">
+ SELECT
+ A.Id AS A_ID,
+ A.A_Libelle AS A_Libelle,
+ B.ID AS B_ID,
+ B.B_Libelle AS B_Libelle,
+ C.ID AS C_ID,
+ C.C_Libelle AS C_Libelle,
+ D.ID AS D_ID,
+ D.D_Libelle AS D_Libelle,
+ E.ID AS E_ID,
+ E.E_Libelle AS E_Libelle,
+ F.ID AS F_ID,
+ F.F_Libelle AS F_Libelle
+ FROM A
+ LEFT OUTER JOIN B ON A.B_ID = B.ID
+ LEFT OUTER JOIN C ON B.C_ID = C.ID
+ LEFT OUTER JOIN D ON B.D_ID = D.ID
+ LEFT OUTER JOIN E ON A.E_ID = E.ID
+ LEFT OUTER JOIN F ON A.F_ID = F.ID
+ </select>
+
+
+ <statement id="DynamicSelectByIntLong"
+ parameterClass="Hashtable"
+ resultMap="other-result">
+ select
+ Other_Int,
+ Other_Long,
+ Other_Bit,
+ Other_String
+ from Others
+ <dynamic prepend="WHERE">
+ <isNotEqual prepend="AND" property="year" compareValue="0">
+ Other_Int = #year#
+ </isNotEqual>
+
+ <isNotEqual prepend="AND" property="areaid" compareValue="0">
+ Other_Long = #areaid#
+ </isNotEqual>
+ </dynamic>
+ </statement>
+
+ <statement id="DynamicSelectByBool"
+ parameterClass="Other"
+ resultMap="other-result">
+ select
+ Other_Int,
+ Other_Long,
+ Other_Bit,
+ Other_String
+ from Others
+ Where Other_Bit = #Bool#
+ </statement>
+
+ <statement id="InsertBool"
+ parameterClass="Other">
+ Insert into Others
+ ( Other_Int, Other_Long, Other_Bit, Other_String )
+ values
+ ( #Int#, #Long#, #Bool#, 'Yes')
+ </statement>
+
+ <statement id="InsertCustomTypeHandler"
+ parameterMap="other-insert-params">
+ Insert into Others
+ ( Other_Int, Other_Long, Other_Bit, Other_String )
+ values
+ ( ?, ?, ?, ?)
+ </statement>
+
+ <statement id="SelectByInt"
+ parameterClass="int"
+ resultMap="other-result">
+ select
+ Other_Int,
+ Other_Long,
+ Other_Bit,
+ Other_String
+ from Others
+ Where Other_Int = #value#
+ </statement>
+
+ <statement id="SelectByIntV1"
+ parameterClass="int"
+ resultMap="other-result-V1">
+ select
+ Other_Int,
+ Other_Long,
+ Other_Bit,
+ Other_String
+ from Others
+ Where Other_Int = #value#
+ </statement>
+
+ <statement id="InsertInlineCustomTypeHandlerV1"
+ parameterClass="Other">
+ Insert into Others
+ ( Other_Int, Other_Long, Other_Bit, Other_String )
+ values
+ ( #Int#, #Long#, #Bool#, #Bool2,type=bool,dbType=Varchar#)
+ </statement>
+
+ <statement id="InsertInlineCustomTypeHandlerV2"
+ parameterClass="Other">
+ Insert into Others
+ ( Other_Int, Other_Long, Other_Bit, Other_String )
+ values
+ ( #Int#, #Long#, #Bool#, #Bool2,typeHandler=OuiNonBool#)
+ </statement>
+
+ <parameterMap id="other-insert-params">
+ <parameter property="Int" />
+ <parameter property="Long" />
+ <parameter property="Bool" />
+ <parameter property="Bool2" typeHandler="OuiNonBool"/>
+ </parameterMap>
+</sqlMap>
diff --git a/tests/unit/Data/SqlMap/maps/sqlite/ResultClass.xml b/tests/unit/Data/SqlMap/maps/sqlite/ResultClass.xml
new file mode 100644
index 00000000..8be5fcca
--- /dev/null
+++ b/tests/unit/Data/SqlMap/maps/sqlite/ResultClass.xml
@@ -0,0 +1,130 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<sqlMap namespace="ResultClass" >
+
+ <statement id="GetBoolean"
+ parameterClass="Int"
+ resultClass="bool" >
+ select 1 from Orders where Order_ID = #dummy#
+ </statement>
+ <statement id="GetBooleanWithoutResultClass"
+ parameterClass="Int"
+ extends="GetBoolean">
+ </statement>
+
+ <statement id="GetByte"
+ parameterClass="Int"
+ resultClass="string" >
+ select 155 from Orders where Order_ID = #value#
+ </statement>
+ <statement id="GetByteWithoutResultClass"
+ parameterClass="Int"
+ extends="GetByte">
+ </statement>
+
+ <!--
+ NOTE: Use MySql 4.0.2 or higher for "cast"
+ -->
+ <statement id="GetChar"
+ parameterClass="Int"
+ resultClass="string" >
+ select 'a' from Orders where Order_ID = #value#
+ </statement>
+ <statement id="GetCharWithoutResultClass"
+ parameterClass="Int"
+ extends="GetChar">
+ </statement>
+
+ <statement id="GetDate"
+ parameterClass="Int"
+ resultClass="TDateTime" >
+ select '2003-02-15 8:15:00' as datetime from Orders where Order_ID = #value#
+ </statement>
+ <statement id="GetDateWithoutResultClass"
+ parameterClass="Int"
+ extends="GetDate">
+ </statement>
+
+ <statement id="GetDecimal"
+ parameterClass="Int"
+ resultClass="float" >
+ select 1.56 from Orders where Order_ID = #value#
+ </statement>
+ <statement id="GetDecimalWithoutResultClass"
+ parameterClass="Int"
+ extends="GetDecimal">
+ </statement>
+
+ <statement id="GetDouble"
+ parameterClass="Int"
+ resultClass="float" >
+ select 99.5 from Orders where Order_ID= #value#
+ </statement>
+ <statement id="GetDoubleWithoutResultClass"
+ parameterClass="Int"
+ extends="GetDouble">
+ </statement>
+
+ <!--
+ Use binary for cast for MySql
+ -->
+ <statement id="GetGuid"
+ parameterClass="Int"
+ resultClass="guid" >
+ select cast('CD5ABF17-4BBC-4C86-92F1-257735414CF4' as binary) from Orders where Order_ID = #value#
+ </statement>
+ <statement id="GetGuidWithoutResultClass" parameterClass="Int" extends="GetGuid">
+ </statement>
+
+ <statement id="GetInt16"
+ parameterClass="Int"
+ resultClass="int" >
+ select 32111 from Orders where Order_ID = #value#
+ </statement>
+ <statement id="GetInt16WithoutResultClass"
+ parameterClass="Int"
+ extends="GetInt16">
+ </statement>
+
+ <statement id="GetInt32"
+ parameterClass="Int"
+ resultClass="int" >
+ select 999999 from Orders where Order_ID = #value#
+ </statement>
+ <statement id="GetInt32WithoutResultClass"
+ parameterClass="Int"
+ extends="GetInt32">
+ </statement>
+
+ <statement id="GetInt64"
+ parameterClass="Int"
+ resultClass="double" >
+ select 9223372036854775800 from Orders where Order_ID = #value#
+ </statement>
+ <statement id="GetInt64WithoutResultClass"
+ parameterClass="Int"
+ extends="GetInt64">
+ </statement>
+
+ <statement id="GetSingle"
+ parameterClass="Int"
+ resultClass="float" >
+ select 92233.5 from Orders where Order_ID = #value#
+ </statement>
+ <statement id="GetSingleWithoutResultClass"
+ parameterClass="Int"
+ extends="GetSingle">
+ </statement>
+
+ <statement id="GetString"
+ parameterClass="Int"
+ resultClass="string" >
+ select 'VISA'
+ from Orders where Order_ID = #value#
+ </statement>
+ <statement id="GetStringWithoutResultClass"
+ parameterClass="Int"
+ extends="GetString">
+ </statement>
+
+</sqlMap> \ No newline at end of file
diff --git a/tests/unit/Data/SqlMap/maps/tests.xml b/tests/unit/Data/SqlMap/maps/tests.xml
new file mode 100644
index 00000000..d2f45c2f
--- /dev/null
+++ b/tests/unit/Data/SqlMap/maps/tests.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<sqlmap>
+
+<statement id="test" parameterClass="array" >
+ <![CDATA[
+ SELECT a.*, b.*
+ FROM img_request a
+ left join hello_mst b on a.img_pat_id=b.pat_id
+ WHERE (img_requested_ap_dt >= #fromdt# and img_requested_ap_dt <= #todt#)
+ ]]>
+</statement>
+
+<select id="GetAllProgress" parameterClass="array" extends="test">
+ <![CDATA[
+ AND img_progress =#status#
+ ]]>
+</select>
+
+</sqlmap> \ No newline at end of file
diff --git a/tests/unit/Data/SqlMap/mssql.xml b/tests/unit/Data/SqlMap/mssql.xml
new file mode 100644
index 00000000..d2bec5d5
--- /dev/null
+++ b/tests/unit/Data/SqlMap/mssql.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<sqlMapConfig>
+
+ <properties resource="properties.config"/>
+
+ <settings>
+ <setting useStatementNamespaces="false"/>
+ <setting cacheModelsEnabled="true"/>
+ </settings>
+
+ <!-- ==== Database configuration ========= -->
+ <provider class="TAdodbProvider" >
+ <!-- connection string set in common.php -->
+ <datasource />
+ </provider>
+
+ <typeHandlers>
+ <typeHandler type="bool" dbType="Varchar" callback="OuiNonBool"/>
+ </typeHandlers>
+
+ <sqlMaps>
+ <sqlMap name="Account" resource="maps/mssql/Account.xml"/>
+ <sqlMap name="DynamicAccount" resource="maps/mssql/DynamicAccount.xml"/>
+ <sqlMap name="Order" resource="maps/mssql/Order.xml"/>
+ <sqlMap name="Category" resource="maps/mssql/Category.xml"/>
+ <sqlMap name="Complex" resource="maps/mssql/Complex.xml"/>
+ <sqlMap name="LineItem" resource="maps/mssql/LineItem.xml"/>
+ <sqlMap name="Enumeration" resource="maps/mssql/Enumeration.xml"/>
+ <sqlMap name="Other" resource="maps/mssql/Other.xml"/>
+ <sqlMap name="ResultClass" resource="maps/mssql/ResultClass.xml"/>
+ <sqlMap name="Document" resource="maps/mssql/Document.xml"/>
+ </sqlMaps>
+</sqlMapConfig> \ No newline at end of file
diff --git a/tests/unit/Data/SqlMap/mysql.xml b/tests/unit/Data/SqlMap/mysql.xml
new file mode 100644
index 00000000..b4ac85b8
--- /dev/null
+++ b/tests/unit/Data/SqlMap/mysql.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<sqlMapConfig>
+
+ <properties>
+ <property name="selectKey" value="select @@IDENTITY as value" />
+ <property name="MyCategoryName" value="'Film'" />
+ <property name="accountName" value="'Joe'" />
+ </properties>
+
+ <typeHandlers>
+ <typeHandler dbType="Varchar" class="OuiNonBool"/>
+ <typeHandler dbType="date" class="TDateTimeHandler" />
+ </typeHandlers>
+
+ <sqlMaps>
+ <sqlMap name="Account" resource="maps/MySql/Account.xml"/>
+ <sqlMap name="DynamicAccount" resource="maps/MySql/DynamicAccount.xml"/>
+ <sqlMap name="Order" resource="maps/MySql/Order.xml"/>
+ <sqlMap name="Category" resource="maps/MySql/Category.xml"/>
+ <sqlMap name="Complex" resource="maps/MySql/Complex.xml"/>
+ <sqlMap name="LineItem" resource="maps/MySql/LineItem.xml"/>
+ <sqlMap name="Enumeration" resource="maps/MySql/Enumeration.xml"/>
+ <sqlMap name="Other" resource="maps/MySql/Other.xml"/>
+ <sqlMap name="ResultClass" resource="maps/MySql/ResultClass.xml"/>
+ <sqlMap name="Document" resource="maps/MySql/Document.xml"/>
+ <sqlMap resource="maps/MySql/ActiveRecord.xml"/>
+ </sqlMaps>
+
+</sqlMapConfig> \ No newline at end of file
diff --git a/tests/unit/Data/SqlMap/properties.config b/tests/unit/Data/SqlMap/properties.config
new file mode 100644
index 00000000..4906531e
--- /dev/null
+++ b/tests/unit/Data/SqlMap/properties.config
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<settings>
+
+ <add key="selectKey" value="select @@IDENTITY as value" />
+ <add key="MyCategoryName" value="'Film'" />
+ <add key="accountName" value="'Joe'" />
+
+</settings>
diff --git a/tests/unit/Data/SqlMap/queryForListLimitTest.php b/tests/unit/Data/SqlMap/queryForListLimitTest.php
new file mode 100644
index 00000000..7038dc68
--- /dev/null
+++ b/tests/unit/Data/SqlMap/queryForListLimitTest.php
@@ -0,0 +1,38 @@
+<?php
+
+require_once(dirname(__FILE__).'/BaseCase.php');
+
+/**
+ * @package System.Data.SqlMap
+ */
+class queryForListLimitTest extends BaseCase
+{
+ function __construct()
+ {
+ parent::__construct();
+
+ $this->initSqlMap();
+
+ //force autoload
+ new Account;
+ }
+
+ function resetDatabase()
+ {
+ $this->initScript('account-init.sql');
+ }
+
+ function test_accounts_limit_2()
+ {
+ $list1 = $this->sqlmap->queryForList('GetAllAccountsAsArrayListViaResultClass',null,null,1,2);
+ $this->assertEqual(count($list1),2);
+
+ $this->assertEqual($list1[0][0],'2');
+ $this->assertEqual($list1[0][1],'Averel');
+ $this->assertEqual($list1[0][2],'Dalton');
+
+ $this->assertEqual($list1[1][0],'3');
+ $this->assertEqual($list1[1][1],'William');
+ $this->assertEqual($list1[1][2],'Dalton');
+ }
+}
diff --git a/tests/unit/Data/SqlMap/resources/data.db b/tests/unit/Data/SqlMap/resources/data.db
new file mode 100644
index 00000000..b8c158cc
--- /dev/null
+++ b/tests/unit/Data/SqlMap/resources/data.db
Binary files differ
diff --git a/tests/unit/Data/SqlMap/resources/person.xml b/tests/unit/Data/SqlMap/resources/person.xml
new file mode 100644
index 00000000..b4d93960
--- /dev/null
+++ b/tests/unit/Data/SqlMap/resources/person.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<sqlMap namespace="Person" >
+
+ <typeAlias alias="Person" type="Person" />
+
+ <resultMap id="SelectResult" class="Person">
+ <result property="ID" column="per_id" />
+ <result property="FirstName" column="per_first_name" />
+ <result property="LastName" column="per_last_name" />
+ <result property="BirthDate" column="per_birth_date" />
+ <result property="WeightInKilograms" column="per_weight_kg" />
+ <result property="HeightInMeters" column="per_height_m" />
+ </resultMap>
+
+ <select id="Person.SelectAll" resultMap="SelectResult">
+ SELECT
+ per_id,
+ per_first_name,
+ per_last_name,
+ per_birth_date,
+ per_weight_kg,
+ per_height_m
+ FROM
+ person
+ </select>
+</sqlMap> \ No newline at end of file
diff --git a/tests/unit/Data/SqlMap/resources/sqlmap.xml b/tests/unit/Data/SqlMap/resources/sqlmap.xml
new file mode 100644
index 00000000..ee24a3ef
--- /dev/null
+++ b/tests/unit/Data/SqlMap/resources/sqlmap.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<sqlMapConfig>
+
+ <provider class="TAdodb">
+ <datasource driver="sqlite" host="resources/test.db" />
+ </provider>
+
+ <sqlMaps>
+ <sqlMap id="Person" resource="person.xml"/>
+ </sqlMaps>
+
+</sqlMapConfig> \ No newline at end of file
diff --git a/tests/unit/Data/SqlMap/resources/test.db b/tests/unit/Data/SqlMap/resources/test.db
new file mode 100644
index 00000000..b8c158cc
--- /dev/null
+++ b/tests/unit/Data/SqlMap/resources/test.db
Binary files differ
diff --git a/tests/unit/Data/SqlMap/resources/tests.db b/tests/unit/Data/SqlMap/resources/tests.db
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/tests/unit/Data/SqlMap/resources/tests.db
diff --git a/tests/unit/Data/SqlMap/scripts/mssql/DBCreation.sql b/tests/unit/Data/SqlMap/scripts/mssql/DBCreation.sql
new file mode 100644
index 00000000..b4e017d7
--- /dev/null
+++ b/tests/unit/Data/SqlMap/scripts/mssql/DBCreation.sql
@@ -0,0 +1,89 @@
+-- MSQL DATABASE
+
+IF EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name = N'IBatisNet')
+ DROP DATABASE [IBatisNet]
+GO
+
+CREATE DATABASE [IBatisNet]
+ COLLATE Latin1_General_CI_AS
+GO
+
+exec sp_dboption N'IBatisNet', N'autoclose', N'true'
+GO
+
+exec sp_dboption N'IBatisNet', N'bulkcopy', N'false'
+GO
+
+exec sp_dboption N'IBatisNet', N'trunc. log', N'true'
+GO
+
+exec sp_dboption N'IBatisNet', N'torn page detection', N'true'
+GO
+
+exec sp_dboption N'IBatisNet', N'read only', N'false'
+GO
+
+exec sp_dboption N'IBatisNet', N'dbo use', N'false'
+GO
+
+exec sp_dboption N'IBatisNet', N'single', N'false'
+GO
+
+exec sp_dboption N'IBatisNet', N'autoshrink', N'true'
+GO
+
+exec sp_dboption N'IBatisNet', N'ANSI null default', N'false'
+GO
+
+exec sp_dboption N'IBatisNet', N'recursive triggers', N'false'
+GO
+
+exec sp_dboption N'IBatisNet', N'ANSI nulls', N'false'
+GO
+
+exec sp_dboption N'IBatisNet', N'concat null yields null', N'false'
+GO
+
+exec sp_dboption N'IBatisNet', N'cursor close on commit', N'false'
+GO
+
+exec sp_dboption N'IBatisNet', N'default to local cursor', N'false'
+GO
+
+exec sp_dboption N'IBatisNet', N'quoted identifier', N'false'
+GO
+
+exec sp_dboption N'IBatisNet', N'ANSI warnings', N'false'
+GO
+
+exec sp_dboption N'IBatisNet', N'auto create statistics', N'true'
+GO
+
+exec sp_dboption N'IBatisNet', N'auto update statistics', N'true'
+GO
+
+if( ( (@@microsoftversion / power(2, 24) = 8) and (@@microsoftversion & 0xffff >= 724) ) or ( (@@microsoftversion / power(2, 24) = 7) and (@@microsoftversion & 0xffff >= 1082) ) )
+ exec sp_dboption N'IBatisNet', N'db chaining', N'false'
+GO
+
+if exists (select * from master.dbo.syslogins where loginname = N'IBatisNet')
+ exec sp_droplogin N'IBatisNet'
+GO
+
+use [IBatisNet]
+GO
+
+if not exists (select * from master.dbo.syslogins where loginname = N'IBatisNet')
+BEGIN
+ declare @logindb nvarchar(132), @loginpass nvarchar(132), @loginlang nvarchar(132)
+ select @logindb = N'IBatisNet', @loginpass=N'test', @loginlang = N'us_english'
+ exec sp_addlogin N'IBatisNet', @loginpass, @logindb, @loginlang
+END
+GO
+
+if not exists (select * from dbo.sysusers where name = N'IBatisNet' and uid < 16382)
+ EXEC sp_grantdbaccess N'IBatisNet', N'IBatisNet'
+GO
+
+exec sp_addrolemember N'db_owner', N'IBatisNet'
+GO \ No newline at end of file
diff --git a/tests/unit/Data/SqlMap/scripts/mssql/DataBase.sql b/tests/unit/Data/SqlMap/scripts/mssql/DataBase.sql
new file mode 100644
index 00000000..75a1f974
--- /dev/null
+++ b/tests/unit/Data/SqlMap/scripts/mssql/DataBase.sql
@@ -0,0 +1,179 @@
+-- MSQL DATABASE 'IBatisNet'
+
+IF EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name = N'IBatisNet')
+ DROP DATABASE [IBatisNet]
+GO
+
+CREATE DATABASE [IBatisNet]
+ COLLATE Latin1_General_CI_AS
+GO
+
+exec sp_dboption N'IBatisNet', N'autoclose', N'true'
+GO
+
+exec sp_dboption N'IBatisNet', N'bulkcopy', N'false'
+GO
+
+exec sp_dboption N'IBatisNet', N'trunc. log', N'true'
+GO
+
+exec sp_dboption N'IBatisNet', N'torn page detection', N'true'
+GO
+
+exec sp_dboption N'IBatisNet', N'read only', N'false'
+GO
+
+exec sp_dboption N'IBatisNet', N'dbo use', N'false'
+GO
+
+exec sp_dboption N'IBatisNet', N'single', N'false'
+GO
+
+exec sp_dboption N'IBatisNet', N'autoshrink', N'true'
+GO
+
+exec sp_dboption N'IBatisNet', N'ANSI null default', N'false'
+GO
+
+exec sp_dboption N'IBatisNet', N'recursive triggers', N'false'
+GO
+
+exec sp_dboption N'IBatisNet', N'ANSI nulls', N'false'
+GO
+
+exec sp_dboption N'IBatisNet', N'concat null yields null', N'false'
+GO
+
+exec sp_dboption N'IBatisNet', N'cursor close on commit', N'false'
+GO
+
+exec sp_dboption N'IBatisNet', N'default to local cursor', N'false'
+GO
+
+exec sp_dboption N'IBatisNet', N'quoted identifier', N'false'
+GO
+
+exec sp_dboption N'IBatisNet', N'ANSI warnings', N'false'
+GO
+
+exec sp_dboption N'IBatisNet', N'auto create statistics', N'true'
+GO
+
+exec sp_dboption N'IBatisNet', N'auto update statistics', N'true'
+GO
+
+if( ( (@@microsoftversion / power(2, 24) = 8) and (@@microsoftversion & 0xffff >= 724) ) or ( (@@microsoftversion / power(2, 24) = 7) and (@@microsoftversion & 0xffff >= 1082) ) )
+ exec sp_dboption N'IBatisNet', N'db chaining', N'false'
+GO
+
+if exists (select * from master.dbo.syslogins where loginname = N'IBatisNet')
+ exec sp_droplogin N'IBatisNet'
+GO
+
+use [IBatisNet]
+GO
+
+if not exists (select * from master.dbo.syslogins where loginname = N'IBatisNet')
+BEGIN
+ declare @logindb nvarchar(132), @loginpass nvarchar(132), @loginlang nvarchar(132)
+ select @logindb = N'IBatisNet', @loginpass=N'test', @loginlang = N'us_english'
+ exec sp_addlogin N'IBatisNet', @loginpass, @logindb, @loginlang
+END
+GO
+
+if not exists (select * from dbo.sysusers where name = N'IBatisNet' and uid < 16382)
+ EXEC sp_grantdbaccess N'IBatisNet', N'IBatisNet'
+GO
+
+exec sp_addrolemember N'db_owner', N'IBatisNet'
+GO
+
+-- MSQL DATABASE 'NHibernate'
+
+IF EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name = N'NHibernate')
+ DROP DATABASE [NHibernate]
+GO
+
+CREATE DATABASE [NHibernate]
+ COLLATE Latin1_General_CI_AS
+GO
+
+exec sp_dboption N'NHibernate', N'autoclose', N'true'
+GO
+
+exec sp_dboption N'NHibernate', N'bulkcopy', N'false'
+GO
+
+exec sp_dboption N'NHibernate', N'trunc. log', N'true'
+GO
+
+exec sp_dboption N'NHibernate', N'torn page detection', N'true'
+GO
+
+exec sp_dboption N'NHibernate', N'read only', N'false'
+GO
+
+exec sp_dboption N'NHibernate', N'dbo use', N'false'
+GO
+
+exec sp_dboption N'NHibernate', N'single', N'false'
+GO
+
+exec sp_dboption N'NHibernate', N'autoshrink', N'true'
+GO
+
+exec sp_dboption N'NHibernate', N'ANSI null default', N'false'
+GO
+
+exec sp_dboption N'NHibernate', N'recursive triggers', N'false'
+GO
+
+exec sp_dboption N'NHibernate', N'ANSI nulls', N'false'
+GO
+
+exec sp_dboption N'NHibernate', N'concat null yields null', N'false'
+GO
+
+exec sp_dboption N'NHibernate', N'cursor close on commit', N'false'
+GO
+
+exec sp_dboption N'NHibernate', N'default to local cursor', N'false'
+GO
+
+exec sp_dboption N'NHibernate', N'quoted identifier', N'false'
+GO
+
+exec sp_dboption N'NHibernate', N'ANSI warnings', N'false'
+GO
+
+exec sp_dboption N'NHibernate', N'auto create statistics', N'true'
+GO
+
+exec sp_dboption N'NHibernate', N'auto update statistics', N'true'
+GO
+
+if( ( (@@microsoftversion / power(2, 24) = 8) and (@@microsoftversion & 0xffff >= 724) ) or ( (@@microsoftversion / power(2, 24) = 7) and (@@microsoftversion & 0xffff >= 1082) ) )
+ exec sp_dboption N'NHibernate', N'db chaining', N'false'
+GO
+
+if exists (select * from master.dbo.syslogins where loginname = N'NHibernate')
+ exec sp_droplogin N'NHibernate'
+GO
+
+use [NHibernate]
+GO
+
+if not exists (select * from master.dbo.syslogins where loginname = N'NHibernate')
+BEGIN
+ declare @logindb nvarchar(132), @loginpass nvarchar(132), @loginlang nvarchar(132)
+ select @logindb = N'NHibernate', @loginpass=N'test', @loginlang = N'us_english'
+ exec sp_addlogin N'NHibernate', @loginpass, @logindb, @loginlang
+END
+GO
+
+if not exists (select * from dbo.sysusers where name = N'NHibernate' and uid < 16382)
+ EXEC sp_grantdbaccess N'NHibernate', N'NHibernate'
+GO
+
+exec sp_addrolemember N'db_owner', N'NHibernate'
+GO \ No newline at end of file
diff --git a/tests/unit/Data/SqlMap/scripts/mssql/README-embed-param.txt b/tests/unit/Data/SqlMap/scripts/mssql/README-embed-param.txt
new file mode 100644
index 00000000..639e61a8
--- /dev/null
+++ b/tests/unit/Data/SqlMap/scripts/mssql/README-embed-param.txt
@@ -0,0 +1,8 @@
+Technique for creating large sample test data from:
+
+http://www.sql-server-performance.com/jc_large_data_operations.asp
+
+Make sure you have enough space and have either enough processing power or
+enough patience to run the Embed Parameters in Statement tests.
+
+Run embed-parameters-setup-init.sql prior to running tests.
diff --git a/tests/unit/Data/SqlMap/scripts/mssql/account-init.sql b/tests/unit/Data/SqlMap/scripts/mssql/account-init.sql
new file mode 100644
index 00000000..4b8e3ece
--- /dev/null
+++ b/tests/unit/Data/SqlMap/scripts/mssql/account-init.sql
@@ -0,0 +1,47 @@
+-- Creating Table
+
+use [IBatisNet]
+
+if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Accounts]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
+BEGIN
+ if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_Orders_Accounts]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
+ ALTER TABLE [dbo].[Orders] DROP CONSTRAINT FK_Orders_Accounts
+
+ drop table [dbo].[Accounts]
+END
+
+CREATE TABLE [dbo].[Accounts] (
+ [Account_ID] [int] NOT NULL ,
+ [Account_FirstName] [varchar] (32) NOT NULL ,
+ [Account_LastName] [varchar] (32) NOT NULL ,
+ [Account_Email] [varchar] (128) NULL,
+ [Account_Banner_Option] [varchar] (255),
+ [Account_Cart_Option] [int]
+) ON [PRIMARY]
+
+ALTER TABLE [dbo].[Accounts] WITH NOCHECK ADD
+ CONSTRAINT [PK_Account] PRIMARY KEY CLUSTERED
+ (
+ [Account_ID]
+ ) ON [PRIMARY]
+
+-- Creating Test Data
+
+INSERT INTO [dbo].[Accounts] VALUES(1,'Joe', 'Dalton', 'Joe.Dalton@somewhere.com', 'Oui', 200);
+INSERT INTO [dbo].[Accounts] VALUES(2,'Averel', 'Dalton', 'Averel.Dalton@somewhere.com', 'Oui', 200);
+INSERT INTO [dbo].[Accounts] VALUES(3,'William', 'Dalton', null, 'Non', 100);
+INSERT INTO [dbo].[Accounts] VALUES(4,'Jack', 'Dalton', 'Jack.Dalton@somewhere.com', 'Non', 100);
+INSERT INTO [dbo].[Accounts] VALUES(5,'Gilles', 'Bayon', null, 'Oui', 100);
+
+-- Store procedure
+
+if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[ps_InsertAccount]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
+drop procedure [dbo].[ps_InsertAccount]
+
+if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[ps_SelectAccount]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
+drop procedure [dbo].[ps_SelectAccount]
+
+if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[ps_swap_email_address]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
+drop procedure [dbo].[ps_swap_email_address]
+
+
diff --git a/tests/unit/Data/SqlMap/scripts/mssql/account-procedure.sql b/tests/unit/Data/SqlMap/scripts/mssql/account-procedure.sql
new file mode 100644
index 00000000..fdb5c3d9
--- /dev/null
+++ b/tests/unit/Data/SqlMap/scripts/mssql/account-procedure.sql
@@ -0,0 +1,12 @@
+CREATE PROCEDURE dbo.[ps_InsertAccount]
+@Account_ID [int],
+@Account_FirstName [nvarchar] (40),
+@Account_LastName [varchar] (32),
+@Account_Email [varchar] (128),
+@Account_Banner_Option [varchar] (255),
+@Account_Cart_Option [int]
+AS
+insert into Accounts
+ (Account_ID, Account_FirstName, Account_LastName, Account_Email, Account_Banner_Option, Account_Cart_Option)
+values
+ (@Account_ID, @Account_FirstName, @Account_LastName, @Account_Email, @Account_Banner_Option, @Account_Cart_Option)
diff --git a/tests/unit/Data/SqlMap/scripts/mssql/category-init.sql b/tests/unit/Data/SqlMap/scripts/mssql/category-init.sql
new file mode 100644
index 00000000..d7a7cfa5
--- /dev/null
+++ b/tests/unit/Data/SqlMap/scripts/mssql/category-init.sql
@@ -0,0 +1,17 @@
+-- Creating Table
+
+use [IBatisNet]
+
+if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Categories]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
+drop table [dbo].[Categories]
+
+CREATE TABLE [dbo].[Categories] (
+ [Category_Id] [int] IDENTITY (1, 1) NOT NULL ,
+ [Category_Name] [varchar] (32) NULL,
+ [Category_Guid] [uniqueidentifier] NULL
+) ON [PRIMARY]
+
+-- Store procedure
+
+if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[ps_InsertCategorie]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
+drop procedure [dbo].[ps_InsertCategorie]
diff --git a/tests/unit/Data/SqlMap/scripts/mssql/category-procedure.sql b/tests/unit/Data/SqlMap/scripts/mssql/category-procedure.sql
new file mode 100644
index 00000000..bf565e87
--- /dev/null
+++ b/tests/unit/Data/SqlMap/scripts/mssql/category-procedure.sql
@@ -0,0 +1,10 @@
+CREATE PROCEDURE dbo.[ps_InsertCategorie]
+@Category_Id [int] output,
+@Category_Name [varchar] (32),
+@Category_Guid [uniqueidentifier]
+AS
+insert into Categories
+ (Category_Name, Category_Guid )
+values
+ (@Category_Name, @Category_Guid)
+SELECT @Category_Id = SCOPE_IDENTITY() \ No newline at end of file
diff --git a/tests/unit/Data/SqlMap/scripts/mssql/documents-init.sql b/tests/unit/Data/SqlMap/scripts/mssql/documents-init.sql
new file mode 100644
index 00000000..b268c258
--- /dev/null
+++ b/tests/unit/Data/SqlMap/scripts/mssql/documents-init.sql
@@ -0,0 +1,34 @@
+-- Creating Table
+
+use [IBatisNet]
+
+if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Documents]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
+BEGIN
+ if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_LineItems_Orders]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
+ ALTER TABLE [dbo].[LineItems] DROP CONSTRAINT FK_LineItems_Orders
+
+ drop table [dbo].[Documents]
+END
+
+CREATE TABLE [dbo].[Documents] (
+ [Document_ID] [int] NOT NULL ,
+ [Document_Title] [varchar] (32) NULL ,
+ [Document_Type] [varchar] (32) NULL ,
+ [Document_PageNumber] [int] NULL ,
+ [Document_City] [varchar] (32) NULL
+) ON [PRIMARY]
+
+ALTER TABLE [dbo].[Documents] WITH NOCHECK ADD
+ CONSTRAINT [PK_Documents] PRIMARY KEY CLUSTERED
+ (
+ [Document_ID]
+ ) ON [PRIMARY]
+
+-- Creating Test Data
+
+INSERT INTO [dbo].[Documents] VALUES (1, 'The World of Null-A', 'Book', 55, null);
+INSERT INTO [dbo].[Documents] VALUES (2, 'Le Progres de Lyon', 'Newspaper', null , 'Lyon');
+INSERT INTO [dbo].[Documents] VALUES (3, 'Lord of the Rings', 'Book', 3587, null);
+INSERT INTO [dbo].[Documents] VALUES (4, 'Le Canard enchaine', 'Tabloid', null , 'Paris');
+INSERT INTO [dbo].[Documents] VALUES (5, 'Le Monde', 'Broadsheet', null , 'Paris');
+INSERT INTO [dbo].[Documents] VALUES (6, 'Foundation', 'Monograph', 557, null);
diff --git a/tests/unit/Data/SqlMap/scripts/mssql/embed-param-setup-init.sql b/tests/unit/Data/SqlMap/scripts/mssql/embed-param-setup-init.sql
new file mode 100644
index 00000000..c0bf20e8
--- /dev/null
+++ b/tests/unit/Data/SqlMap/scripts/mssql/embed-param-setup-init.sql
@@ -0,0 +1,94 @@
+-- Technique for creating large sample test data from
+-- http://www.sql-server-performance.com/jc_large_data_operations.asp
+
+use [IBatisNet]
+
+if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[ManyRecords]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
+drop table [dbo].[ManyRecords]
+
+if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[ManyRecordsTest]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
+drop table [dbo].[ManyRecordsTest]
+
+
+
+-- Create Data Storage Table
+CREATE TABLE [dbo].[ManyRecords] (
+ [Many_FirstID] [int] NOT NULL,
+ [Many_SecondID] [int] NOT NULL,
+ [Many_ThirdID] [int] NOT NULL,
+ [Many_FourthID] [int] NOT NULL,
+ [Many_FifthID] [int] NOT NULL,
+ [Many_SequenceID] [int] NOT NULL,
+ [Many_DistributedID] [int] NOT NULL,
+ [Many_SampleCharValue] [char] (10) NOT NULL,
+ [Many_SampleDecimal] [decimal] (9,4) NOT NULL,
+ [Many_SampleMoney] [money] NOT NULL,
+ [Many_SampleDate] [datetime] NOT NULL,
+ [Many_SequenceDate] [datetime] NOT NULL )
+ON [PRIMARY]
+
+
+
+-- Create Sample Data of 1 million records (increase if needed)
+BEGIN TRANSACTION
+ DECLARE @intIndex int, @rowCount int, @seqCount int, @distValue int
+ SELECT @intIndex = 1, @rowCount = 1000000, @seqCount = 10000
+ SELECT @distValue = @rowCount/10000
+
+ WHILE @intIndex <= @rowCount
+ BEGIN
+ INSERT INTO [dbo].[ManyRecords] (
+ [Many_FirstID],
+ [Many_SecondID],
+ [Many_ThirdID],
+ [Many_FourthID],
+ [Many_FifthID],
+ [Many_SequenceID],
+ [Many_DistributedID],
+ [Many_SampleCharValue],
+ [Many_SampleDecimal],
+ [Many_SampleMoney],
+ [Many_SampleDate],
+ [Many_SequenceDate] )
+ VALUES (
+ @intIndex, -- First
+ @intIndex/2, -- Second
+ @intIndex/4, -- Third
+ @intIndex/10, -- Fourth
+ @intIndex/20, -- Fifth
+ (@intIndex-1)/@seqCount + 1, -- Sequential value
+ (@intIndex-1)%(@distValue) + 1, -- Distributed value
+ CHAR(65 + 26*rand())+CHAR(65 + 26*rand())+CHAR(65 + 26*rand())+CONVERT(char(6),CONVERT(int,100000*(9.0*rand()+1.0)))+CHAR(65 + 26*rand()), -- Char Value
+ 10000*rand(), -- Decimal value
+ 10000*rand(), -- Money value
+ DATEADD(hour,100000*rand(),'1990-01-01'), -- Date value
+ DATEADD(hour,@intIndex/5,'1990-01-01') ) -- Sequential date value
+
+ SET @intIndex = @intIndex + 1
+ END
+COMMIT TRANSACTION
+
+
+
+-- Create Test table using storage table sample data
+SELECT
+ [Many_FirstID],
+ [Many_SecondID],
+ [Many_ThirdID],
+ [Many_FourthID],
+ [Many_FifthID],
+ [Many_SequenceID],
+ [Many_DistributedID],
+ [Many_SampleCharValue],
+ [Many_SampleDecimal],
+ [Many_SampleMoney],
+ [Many_SampleDate],
+ [Many_SequenceDate]
+INTO [dbo].[ManyRecordsTest]
+FROM [dbo].[ManyRecords]
+
+
+
+-- Create Test table indexes
+CREATE INDEX [IDX_ManyRecordsTest_Seq] ON [dbo].[ManyRecordsTest] ([Many_SequenceID]) WITH SORT_IN_TEMPDB
+CREATE INDEX [IDX_ManyRecordsTest_Dist] ON [dbo].[ManyRecordsTest] ([Many_DistributedID]) WITH SORT_IN_TEMPDB \ No newline at end of file
diff --git a/tests/unit/Data/SqlMap/scripts/mssql/embed-param-test-init.sql b/tests/unit/Data/SqlMap/scripts/mssql/embed-param-test-init.sql
new file mode 100644
index 00000000..f776b158
--- /dev/null
+++ b/tests/unit/Data/SqlMap/scripts/mssql/embed-param-test-init.sql
@@ -0,0 +1,32 @@
+-- Technique for creating large sample test data from
+-- http://www.sql-server-performance.com/jc_large_data_operations.asp
+
+use [IBatisNet]
+
+if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[ManyRecordsTest]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
+drop table [dbo].[ManyRecordsTest]
+
+
+
+-- Create Test table using storage table sample data
+SELECT
+ [Many_FirstID],
+ [Many_SecondID],
+ [Many_ThirdID],
+ [Many_FourthID],
+ [Many_FifthID],
+ [Many_SequenceID],
+ [Many_DistributedID],
+ [Many_SampleCharValue],
+ [Many_SampleDecimal],
+ [Many_SampleMoney],
+ [Many_SampleDate],
+ [Many_SequenceDate]
+INTO [dbo].[ManyRecordsTest]
+FROM [dbo].[ManyRecords]
+
+
+
+-- Create Test table indexes
+CREATE INDEX [IDX_ManyRecordsTest_Seq] ON [dbo].[ManyRecordsTest] ([Many_SequenceID]) WITH SORT_IN_TEMPDB
+CREATE INDEX [IDX_ManyRecordsTest_Dist] ON [dbo].[ManyRecordsTest] ([Many_DistributedID]) WITH SORT_IN_TEMPDB \ No newline at end of file
diff --git a/tests/unit/Data/SqlMap/scripts/mssql/enumeration-init.sql b/tests/unit/Data/SqlMap/scripts/mssql/enumeration-init.sql
new file mode 100644
index 00000000..65b1e26f
--- /dev/null
+++ b/tests/unit/Data/SqlMap/scripts/mssql/enumeration-init.sql
@@ -0,0 +1,30 @@
+-- Creating Table
+
+use [IBatisNet]
+
+if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Enumerations]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
+BEGIN
+ drop table [dbo].[Enumerations]
+END
+
+CREATE TABLE [dbo].[Enumerations] (
+ [Enum_ID] [int] NOT NULL ,
+ [Enum_Day] [int] NOT NULL ,
+ [Enum_Color] [int] NOT NULL,
+ [Enum_Month] [int] NULL
+) ON [PRIMARY]
+
+ALTER TABLE [dbo].[Enumerations] WITH NOCHECK ADD
+ CONSTRAINT [PK_Enum] PRIMARY KEY CLUSTERED
+ (
+ [Enum_ID]
+ ) ON [PRIMARY]
+
+-- Creating Test Data
+
+INSERT INTO [dbo].[Enumerations] VALUES(1, 1, 1, 128);
+INSERT INTO [dbo].[Enumerations] VALUES(2, 2, 2, 2048);
+INSERT INTO [dbo].[Enumerations] VALUES(3, 3, 4, 256);
+INSERT INTO [dbo].[Enumerations] VALUES(4, 4, 8, null);
+
+
diff --git a/tests/unit/Data/SqlMap/scripts/mssql/line-item-init.sql b/tests/unit/Data/SqlMap/scripts/mssql/line-item-init.sql
new file mode 100644
index 00000000..e25a49dd
--- /dev/null
+++ b/tests/unit/Data/SqlMap/scripts/mssql/line-item-init.sql
@@ -0,0 +1,53 @@
+-- Creating Table
+
+use [IBatisNet]
+
+if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[LineItems]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
+drop table [dbo].[LineItems]
+
+CREATE TABLE [dbo].[LineItems] (
+ [LineItem_ID] [int] NOT NULL ,
+ [Order_ID] [int] NOT NULL ,
+ [LineItem_Code] [varchar] (32) NOT NULL ,
+ [LineItem_Quantity] [int] NOT NULL ,
+ [LineItem_Price] [decimal](18, 2) NULL,
+ [LineItem_Picture] [image] null
+) ON [PRIMARY]
+
+ALTER TABLE [dbo].[LineItems] WITH NOCHECK ADD
+ CONSTRAINT [PK_LinesItem] PRIMARY KEY CLUSTERED
+ (
+ [LineItem_ID],
+ [Order_ID]
+ ) ON [PRIMARY]
+
+ALTER TABLE [dbo].[LineItems] ADD
+ CONSTRAINT [FK_LineItems_Orders] FOREIGN KEY
+ (
+ [Order_ID]
+ ) REFERENCES [dbo].[Orders] (
+ [Order_ID]
+ )
+-- Creating Test Data
+
+INSERT INTO [dbo].[LineItems] VALUES (1, 10, 'ESM-34', 1, 45.43, null);
+INSERT INTO [dbo].[LineItems] VALUES (2, 10, 'QSM-98', 8, 8.40, null);
+INSERT INTO [dbo].[LineItems] VALUES (1, 9, 'DSM-78', 2, 45.40, null);
+INSERT INTO [dbo].[LineItems] VALUES (2, 9, 'TSM-12', 2, 32.12, null);
+INSERT INTO [dbo].[LineItems] VALUES (1, 8, 'DSM-16', 4, 41.30, null);
+INSERT INTO [dbo].[LineItems] VALUES (2, 8, 'GSM-65', 1, 2.20, null);
+INSERT INTO [dbo].[LineItems] VALUES (1, 7, 'WSM-27', 7, 52.10, null);
+INSERT INTO [dbo].[LineItems] VALUES (2, 7, 'ESM-23', 2, 123.34, null);
+INSERT INTO [dbo].[LineItems] VALUES (1, 6, 'QSM-39', 9, 12.12, null);
+INSERT INTO [dbo].[LineItems] VALUES (2, 6, 'ASM-45', 6, 78.77, null);
+INSERT INTO [dbo].[LineItems] VALUES (1, 5, 'ESM-48', 3, 43.87, null);
+INSERT INTO [dbo].[LineItems] VALUES (2, 5, 'WSM-98', 7, 5.40, null);
+INSERT INTO [dbo].[LineItems] VALUES (1, 4, 'RSM-57', 2, 78.90, null);
+INSERT INTO [dbo].[LineItems] VALUES (2, 4, 'XSM-78', 9, 2.34, null);
+INSERT INTO [dbo].[LineItems] VALUES (1, 3, 'DSM-59', 3, 5.70, null);
+INSERT INTO [dbo].[LineItems] VALUES (2, 3, 'DSM-53', 3, 98.78, null);
+INSERT INTO [dbo].[LineItems] VALUES (1, 2, 'DSM-37', 4, 7.80, null);
+INSERT INTO [dbo].[LineItems] VALUES (2, 2, 'FSM-12', 2, 55.78, null);
+INSERT INTO [dbo].[LineItems] VALUES (1, 1, 'ESM-48', 8, 87.60, null);
+INSERT INTO [dbo].[LineItems] VALUES (2, 1, 'ESM-23', 1, 55.40, null);
+
diff --git a/tests/unit/Data/SqlMap/scripts/mssql/more-account-records.sql b/tests/unit/Data/SqlMap/scripts/mssql/more-account-records.sql
new file mode 100644
index 00000000..e526309d
--- /dev/null
+++ b/tests/unit/Data/SqlMap/scripts/mssql/more-account-records.sql
@@ -0,0 +1,11 @@
+
+
+
+-- Creating Test Data
+
+INSERT INTO [dbo].[Accounts] VALUES(6,'Jane', 'Calamity', 'Jane.Calamity@somewhere.com', 'Oui', 200);
+INSERT INTO [dbo].[Accounts] VALUES(7,'Lucky', 'Luke', 'Lucky.Luke@somewhere.com', 'Oui', 200);
+INSERT INTO [dbo].[Accounts] VALUES(8,'Ming', 'Li Foo', null, 'Non', 100);
+INSERT INTO [dbo].[Accounts] VALUES(9,'O''Hara', 'Steve', 'Jack.OHara@somewhere.com', 'Oui', 200);
+INSERT INTO [dbo].[Accounts] VALUES(10,'Robert', 'O''Timmins', null, 'Non', 100);
+
diff --git a/tests/unit/Data/SqlMap/scripts/mssql/order-init.sql b/tests/unit/Data/SqlMap/scripts/mssql/order-init.sql
new file mode 100644
index 00000000..0f1e2438
--- /dev/null
+++ b/tests/unit/Data/SqlMap/scripts/mssql/order-init.sql
@@ -0,0 +1,54 @@
+-- Creating Table
+
+use [IBatisNet]
+
+if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Orders]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
+BEGIN
+ if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_LineItems_Orders]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
+ ALTER TABLE [dbo].[LineItems] DROP CONSTRAINT FK_LineItems_Orders
+
+ drop table [dbo].[Orders]
+END
+
+CREATE TABLE [dbo].[Orders] (
+ [Order_ID] [int] NOT NULL ,
+ [Account_ID] [int] NULL ,
+ [Order_Date] [datetime] NULL ,
+ [Order_CardType] [varchar] (32) NULL ,
+ [Order_CardNumber] [varchar] (32) NULL ,
+ [Order_CardExpiry] [varchar] (32) NULL ,
+ [Order_Street] [varchar] (32) NULL ,
+ [Order_City] [varchar] (32) NULL ,
+ [Order_Province] [varchar] (32) NULL ,
+ [Order_PostalCode] [varchar] (32) NULL ,
+ [Order_FavouriteLineItem] [int] NULL
+) ON [PRIMARY]
+
+ALTER TABLE [dbo].[Orders] WITH NOCHECK ADD
+ CONSTRAINT [PK_Orders] PRIMARY KEY CLUSTERED
+ (
+ [Order_ID]
+ ) ON [PRIMARY]
+
+
+ALTER TABLE [dbo].[Orders] ADD
+ CONSTRAINT [FK_Orders_Accounts] FOREIGN KEY
+ (
+ [Account_ID]
+ ) REFERENCES [dbo].[Accounts] (
+ [Account_ID]
+ )
+-- Creating Test Data -- 2003-02-15 8:15:00/ 2003-02-15 8:15:00
+
+INSERT INTO [dbo].[Orders] VALUES (1, 1, '2003-02-15 8:15:00', 'VISA', '999999999999', '05/03', '11 This Street', 'Victoria', 'BC', 'C4B 4F4',2);
+INSERT INTO [dbo].[Orders] VALUES (2, 4, '2003-02-15 8:15:00', 'MC', '888888888888', '06/03', '222 That Street', 'Edmonton', 'AB', 'X4K 5Y4',1);
+INSERT INTO [dbo].[Orders] VALUES (3, 3, '2003-02-15 8:15:00', 'AMEX', '777777777777', '07/03', '333 Other Street', 'Regina', 'SK', 'Z4U 6Y4',2);
+INSERT INTO [dbo].[Orders] VALUES (4, 2, '2003-02-15 8:15:00', 'MC', '666666666666', '08/03', '444 His Street', 'Toronto', 'ON', 'K4U 3S4',1);
+INSERT INTO [dbo].[Orders] VALUES (5, 5, '2003-02-15 8:15:00', 'VISA', '555555555555', '09/03', '555 Her Street', 'Calgary', 'AB', 'J4J 7S4',2);
+INSERT INTO [dbo].[Orders] VALUES (6, 5, '2003-02-15 8:15:00', 'VISA', '999999999999', '10/03', '6 Their Street', 'Victoria', 'BC', 'T4H 9G4',1);
+INSERT INTO [dbo].[Orders] VALUES (7, 4, '2003-02-15 8:15:00', 'MC', '888888888888', '11/03', '77 Lucky Street', 'Edmonton', 'AB', 'R4A 0Z4',2);
+INSERT INTO [dbo].[Orders] VALUES (8, 3, '2003-02-15 8:15:00', 'AMEX', '777777777777', '12/03', '888 Our Street', 'Regina', 'SK', 'S4S 7G4',1);
+INSERT INTO [dbo].[Orders] VALUES (9, 2, '2003-02-15 8:15:00', 'MC', '666666666666', '01/04', '999 Your Street', 'Toronto', 'ON', 'G4D 9F4',2);
+INSERT INTO [dbo].[Orders] VALUES (10, 1, '2003-02-15 8:15:00', 'VISA', '555555555555', '02/04', '99 Some Street', 'Calgary', 'AB', 'W4G 7A4',1);
+INSERT INTO [dbo].[Orders] VALUES (11, null, '2003-02-15 8:15:00', 'VISA', '555555555555', '02/04', 'Null order', 'Calgary', 'ZZ', 'XXX YYY',1);
+
diff --git a/tests/unit/Data/SqlMap/scripts/mssql/other-init.sql b/tests/unit/Data/SqlMap/scripts/mssql/other-init.sql
new file mode 100644
index 00000000..645a6eea
--- /dev/null
+++ b/tests/unit/Data/SqlMap/scripts/mssql/other-init.sql
@@ -0,0 +1,145 @@
+-- Creating Table
+
+use [IBatisNet]
+
+if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Others]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
+BEGIN
+ drop table [dbo].[Others]
+END
+
+if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[A]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
+BEGIN
+ drop table [dbo].[A]
+END
+if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[B]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
+BEGIN
+ drop table [dbo].[B]
+END
+if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[C]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
+BEGIN
+ drop table [dbo].[C]
+END
+if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[D]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
+BEGIN
+ drop table [dbo].[D]
+END
+if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[E]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
+BEGIN
+ drop table [dbo].[E]
+END
+if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[F]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
+BEGIN
+ drop table [dbo].[F]
+END
+
+
+CREATE TABLE [dbo].[Others] (
+ [Other_Int] [int] NULL ,
+ [Other_Long] [BigInt] NULL,
+ [Other_Bit] [Bit] NOT NULL DEFAULT (0),
+ [Other_String] [varchar] (32) NOT NULL
+) ON [PRIMARY]
+
+CREATE TABLE [dbo].[F] (
+ [ID] [varchar] (50) NOT NULL ,
+ [F_Libelle] [varchar] (50) NULL ,
+ CONSTRAINT [PK_F] PRIMARY KEY CLUSTERED
+ (
+ [ID]
+ ) ON [PRIMARY]
+) ON [PRIMARY]
+
+CREATE TABLE [dbo].[E] (
+ [ID] [varchar] (50) NOT NULL ,
+ [E_Libelle] [varchar] (50) NULL ,
+ CONSTRAINT [PK_E] PRIMARY KEY CLUSTERED
+ (
+ [ID]
+ ) ON [PRIMARY]
+) ON [PRIMARY]
+
+CREATE TABLE [dbo].[D] (
+ [ID] [varchar] (50) NOT NULL ,
+ [D_Libelle] [varchar] (50) NULL ,
+ CONSTRAINT [PK_D] PRIMARY KEY CLUSTERED
+ (
+ [ID]
+ ) ON [PRIMARY]
+) ON [PRIMARY]
+
+CREATE TABLE [dbo].[C] (
+ [ID] [varchar] (50) NOT NULL ,
+ [C_Libelle] [varchar] (50) NULL ,
+ CONSTRAINT [PK_C] PRIMARY KEY CLUSTERED
+ (
+ [ID]
+ ) ON [PRIMARY]
+) ON [PRIMARY]
+
+
+CREATE TABLE [dbo].[B] (
+ [ID] [varchar] (50) NOT NULL ,
+ [C_ID] [varchar] (50) NULL ,
+ [D_ID] [varchar] (50) NULL ,
+ [B_Libelle] [varchar] (50) NULL ,
+ CONSTRAINT [PK_B] PRIMARY KEY CLUSTERED
+ (
+ [ID]
+ ) ON [PRIMARY] ,
+ CONSTRAINT [FK_B_C] FOREIGN KEY
+ (
+ [C_ID]
+ ) REFERENCES [C] (
+ [ID]
+ ),
+ CONSTRAINT [FK_B_D] FOREIGN KEY
+ (
+ [D_ID]
+ ) REFERENCES [D] (
+ [ID]
+ )
+) ON [PRIMARY]
+
+
+CREATE TABLE [dbo].[A] (
+ [Id] [varchar] (50) NOT NULL ,
+ [B_ID] [varchar] (50) NULL ,
+ [E_ID] [varchar] (50) NULL ,
+ [F_ID] [varchar] (50) NULL ,
+ [A_Libelle] [varchar] (50) NULL
+ CONSTRAINT [PK_A] PRIMARY KEY CLUSTERED
+ (
+ [Id]
+ ) ON [PRIMARY] ,
+ CONSTRAINT [FK_A_B] FOREIGN KEY
+ (
+ [B_ID]
+ ) REFERENCES [B] (
+ [ID]
+ ),
+ CONSTRAINT [FK_A_E] FOREIGN KEY
+ (
+ [E_ID]
+ ) REFERENCES [E] (
+ [ID]
+ ),
+ CONSTRAINT [FK_A_F] FOREIGN KEY
+ (
+ [F_ID]
+ ) REFERENCES [F] (
+ [ID]
+ )
+) ON [PRIMARY]
+
+
+-- Creating Test Data
+
+INSERT INTO [dbo].[Others] VALUES(1, 8888888, 0, 'Oui');
+INSERT INTO [dbo].[Others] VALUES(2, 9999999999, 1, 'Non');
+
+INSERT INTO [dbo].[F] VALUES('f', 'fff');
+INSERT INTO [dbo].[E] VALUES('e', 'eee');
+INSERT INTO [dbo].[D] VALUES('d', 'ddd');
+INSERT INTO [dbo].[C] VALUES('c', 'ccc');
+INSERT INTO [dbo].[B] VALUES('b', 'c', null, 'bbb');
+INSERT INTO [dbo].[A] VALUES('a', 'b', 'e', null, 'aaa'); \ No newline at end of file
diff --git a/tests/unit/Data/SqlMap/scripts/mssql/ps_SelectAccount.sql b/tests/unit/Data/SqlMap/scripts/mssql/ps_SelectAccount.sql
new file mode 100644
index 00000000..bf3ae13d
--- /dev/null
+++ b/tests/unit/Data/SqlMap/scripts/mssql/ps_SelectAccount.sql
@@ -0,0 +1,10 @@
+CREATE PROCEDURE dbo.[ps_SelectAccount]
+@Account_ID [int]
+AS
+select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress
+from Accounts
+where Account_ID = @Account_ID \ No newline at end of file
diff --git a/tests/unit/Data/SqlMap/scripts/mssql/swap-procedure.sql b/tests/unit/Data/SqlMap/scripts/mssql/swap-procedure.sql
new file mode 100644
index 00000000..981ffc5f
--- /dev/null
+++ b/tests/unit/Data/SqlMap/scripts/mssql/swap-procedure.sql
@@ -0,0 +1,34 @@
+CREATE PROCEDURE dbo.[ps_swap_email_address]
+@First_Email [nvarchar] (64) output,
+@Second_Email [nvarchar] (64) output
+AS
+
+Declare @ID1 int
+Declare @ID2 int
+
+Declare @Email1 [nvarchar] (64)
+Declare @Email2 [nvarchar] (64)
+
+ SELECT @ID1 = Account_ID, @Email1 = Account_Email
+ from Accounts
+ where Account_Email = @First_Email
+
+ SELECT @ID2 = Account_ID, @Email2 = Account_Email
+ from Accounts
+ where Account_Email = @Second_Email
+
+ UPDATE Accounts
+ set Account_Email = @Email2
+ where Account_ID = @ID1
+
+ UPDATE Accounts
+ set Account_Email = @Email1
+ where Account_ID = @ID2
+
+ SELECT @First_Email = Account_Email
+ from Accounts
+ where Account_ID = @ID1
+
+ SELECT @Second_Email = Account_Email
+ from Accounts
+ where Account_ID = @ID2
diff --git a/tests/unit/Data/SqlMap/scripts/mssql/user-init.sql b/tests/unit/Data/SqlMap/scripts/mssql/user-init.sql
new file mode 100644
index 00000000..7551da42
--- /dev/null
+++ b/tests/unit/Data/SqlMap/scripts/mssql/user-init.sql
@@ -0,0 +1,17 @@
+-- Creating Table
+
+use [NHibernate]
+
+if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Users]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
+BEGIN
+ drop table [dbo].[Users]
+END
+
+CREATE TABLE [dbo].[Users] (
+ LogonID nvarchar(20) NOT NULL default '0',
+ Name nvarchar(40) default NULL,
+ Password nvarchar(20) default NULL,
+ EmailAddress nvarchar(40) default NULL,
+ LastLogon datetime default NULL,
+ PRIMARY KEY (LogonID)
+)
diff --git a/tests/unit/Data/SqlMap/scripts/mysql/DataBase.sql b/tests/unit/Data/SqlMap/scripts/mysql/DataBase.sql
new file mode 100644
index 00000000..159b1f4a
--- /dev/null
+++ b/tests/unit/Data/SqlMap/scripts/mysql/DataBase.sql
@@ -0,0 +1,356 @@
+--
+-- Table structure for table `A`
+--
+
+DROP TABLE IF EXISTS `A`;
+CREATE TABLE `A` (
+ `ID` varchar(50) NOT NULL,
+ `B_ID` varchar(50) default NULL,
+ `E_ID` varchar(50) default NULL,
+ `F_ID` varchar(50) default NULL,
+ `A_Libelle` varchar(50) default NULL,
+ PRIMARY KEY (`ID`),
+ KEY `FK_A_B` (`B_ID`),
+ KEY `FK_A_E` (`E_ID`),
+ KEY `FK_A_F` (`F_ID`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+--
+-- Dumping data for table `A`
+--
+
+INSERT INTO `A` (`ID`, `B_ID`, `E_ID`, `F_ID`, `A_Libelle`) VALUES ('a', 'b', 'e', NULL, 'aaa');
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `Accounts`
+--
+
+DROP TABLE IF EXISTS `Accounts`;
+CREATE TABLE `Accounts` (
+ `Account_Id` int(11) NOT NULL,
+ `Account_FirstName` varchar(32) NOT NULL,
+ `Account_LastName` varchar(32) NOT NULL,
+ `Account_Email` varchar(128) default NULL,
+ `Account_Banner_Option` varchar(255) default NULL,
+ `Account_Cart_Option` int(11) default NULL,
+ PRIMARY KEY (`Account_Id`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+--
+-- Dumping data for table `Accounts`
+--
+
+INSERT INTO `Accounts` (`Account_Id`, `Account_FirstName`, `Account_LastName`, `Account_Email`, `Account_Banner_Option`, `Account_Cart_Option`) VALUES (1, 'Joe', 'Dalton', 'Joe.Dalton@somewhere.com', 'Oui', 200),
+(2, 'Averel', 'Dalton', 'Averel.Dalton@somewhere.com', 'Oui', 200),
+(3, 'William', 'Dalton', NULL, 'Non', 100),
+(4, 'Jack', 'Dalton', 'Jack.Dalton@somewhere.com', 'Non', 100),
+(5, 'Gilles', 'Bayon', NULL, 'Oui', 100);
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `B`
+--
+
+DROP TABLE IF EXISTS `B`;
+CREATE TABLE `B` (
+ `ID` varchar(50) NOT NULL,
+ `C_ID` varchar(50) default NULL,
+ `D_ID` varchar(50) default NULL,
+ `B_Libelle` varchar(50) default NULL,
+ PRIMARY KEY (`ID`),
+ KEY `FK_B_C` (`C_ID`),
+ KEY `FK_B_D` (`D_ID`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+--
+-- Dumping data for table `B`
+--
+
+INSERT INTO `B` (`ID`, `C_ID`, `D_ID`, `B_Libelle`) VALUES ('b', 'c', NULL, 'bbb');
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `C`
+--
+
+DROP TABLE IF EXISTS `C`;
+CREATE TABLE `C` (
+ `ID` varchar(50) NOT NULL,
+ `C_Libelle` varchar(50) default NULL,
+ PRIMARY KEY (`ID`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+--
+-- Dumping data for table `C`
+--
+
+INSERT INTO `C` (`ID`, `C_Libelle`) VALUES ('c', 'ccc');
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `Categories`
+--
+
+DROP TABLE IF EXISTS `Categories`;
+CREATE TABLE `Categories` (
+ `Category_Id` int(11) NOT NULL auto_increment,
+ `Category_Name` varchar(32) default NULL,
+ `Category_Guid` varchar(36) default NULL,
+ PRIMARY KEY (`Category_Id`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
+
+--
+-- Dumping data for table `Categories`
+--
+
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `D`
+--
+
+DROP TABLE IF EXISTS `D`;
+CREATE TABLE `D` (
+ `ID` varchar(50) NOT NULL,
+ `D_Libelle` varchar(50) default NULL,
+ PRIMARY KEY (`ID`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+--
+-- Dumping data for table `D`
+--
+
+INSERT INTO `D` (`ID`, `D_Libelle`) VALUES ('d', 'ddd');
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `Documents`
+--
+
+DROP TABLE IF EXISTS `Documents`;
+CREATE TABLE `Documents` (
+ `Document_Id` int(11) NOT NULL,
+ `Document_Title` varchar(32) default NULL,
+ `Document_Type` varchar(32) default NULL,
+ `Document_PageNumber` int(11) default NULL,
+ `Document_City` varchar(32) default NULL,
+ PRIMARY KEY (`Document_Id`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+--
+-- Dumping data for table `Documents`
+--
+
+INSERT INTO `Documents` (`Document_Id`, `Document_Title`, `Document_Type`, `Document_PageNumber`, `Document_City`) VALUES (1, 'The World of Null-A', 'Book', 55, NULL),
+(2, 'Le Progres de Lyon', 'Newspaper', NULL, 'Lyon'),
+(3, 'Lord of the Rings', 'Book', 3587, NULL),
+(4, 'Le Canard enchaine', 'Tabloid', NULL, 'Paris'),
+(5, 'Le Monde', 'Broadsheet', NULL, 'Paris'),
+(6, 'Foundation', 'Monograph', 557, NULL);
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `E`
+--
+
+DROP TABLE IF EXISTS `E`;
+CREATE TABLE `E` (
+ `ID` varchar(50) NOT NULL,
+ `E_Libelle` varchar(50) default NULL,
+ PRIMARY KEY (`ID`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+--
+-- Dumping data for table `E`
+--
+
+INSERT INTO `E` (`ID`, `E_Libelle`) VALUES ('e', 'eee');
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `Enumerations`
+--
+
+DROP TABLE IF EXISTS `Enumerations`;
+CREATE TABLE `Enumerations` (
+ `Enum_Id` int(11) NOT NULL,
+ `Enum_Day` int(11) NOT NULL,
+ `Enum_Color` int(11) NOT NULL,
+ `Enum_Month` int(11) default NULL,
+ PRIMARY KEY (`Enum_Id`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+--
+-- Dumping data for table `Enumerations`
+--
+
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `F`
+--
+
+DROP TABLE IF EXISTS `F`;
+CREATE TABLE `F` (
+ `ID` varchar(50) NOT NULL,
+ `F_Libelle` varchar(50) default NULL,
+ PRIMARY KEY (`ID`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+--
+-- Dumping data for table `F`
+--
+
+INSERT INTO `F` (`ID`, `F_Libelle`) VALUES ('f', 'fff');
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `LineItems`
+--
+
+DROP TABLE IF EXISTS `LineItems`;
+CREATE TABLE `LineItems` (
+ `LineItem_Id` int(11) NOT NULL,
+ `Order_Id` int(11) NOT NULL,
+ `LineItem_Code` varchar(32) NOT NULL,
+ `LineItem_Quantity` int(11) NOT NULL,
+ `LineItem_Price` decimal(18,2) default NULL,
+ `LineItem_Picture` blob,
+ PRIMARY KEY (`Order_Id`,`LineItem_Id`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+--
+-- Dumping data for table `LineItems`
+--
+
+INSERT INTO `LineItems` (`LineItem_Id`, `Order_Id`, `LineItem_Code`, `LineItem_Quantity`, `LineItem_Price`, `LineItem_Picture`) VALUES (1, 1, 'ESM-48', 8, 87.60, NULL),
+(2, 1, 'ESM-23', 1, 55.40, NULL),
+(1, 2, 'DSM-37', 4, 7.80, NULL),
+(2, 2, 'FSM-12', 2, 55.78, NULL),
+(1, 3, 'DSM-59', 3, 5.70, NULL),
+(2, 3, 'DSM-53', 3, 98.78, NULL),
+(1, 4, 'RSM-57', 2, 78.90, NULL),
+(2, 4, 'XSM-78', 9, 2.34, NULL),
+(1, 5, 'ESM-48', 3, 43.87, NULL),
+(2, 5, 'WSM-98', 7, 5.40, NULL),
+(1, 6, 'QSM-39', 9, 12.12, NULL),
+(2, 6, 'ASM-45', 6, 78.77, NULL),
+(1, 7, 'WSM-27', 7, 52.10, NULL),
+(2, 7, 'ESM-23', 2, 123.34, NULL),
+(1, 8, 'DSM-16', 4, 41.30, NULL),
+(2, 8, 'GSM-65', 1, 2.20, NULL),
+(1, 9, 'DSM-78', 2, 45.40, NULL),
+(2, 9, 'TSM-12', 2, 32.12, NULL),
+(1, 10, 'ESM-34', 1, 45.43, NULL),
+(2, 10, 'QSM-98', 8, 8.40, NULL);
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `Orders`
+--
+
+DROP TABLE IF EXISTS `Orders`;
+CREATE TABLE `Orders` (
+ `Order_Id` int(11) NOT NULL,
+ `Account_Id` int(11) default NULL,
+ `Order_Date` datetime default NULL,
+ `Order_CardType` varchar(32) default NULL,
+ `Order_CardNumber` varchar(32) default NULL,
+ `Order_CardExpiry` varchar(32) default NULL,
+ `Order_Street` varchar(32) default NULL,
+ `Order_City` varchar(32) default NULL,
+ `Order_Province` varchar(32) default NULL,
+ `Order_PostalCode` varchar(32) default NULL,
+ `Order_FavouriteLineItem` int(11) default NULL,
+ PRIMARY KEY (`Order_Id`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+--
+-- Dumping data for table `Orders`
+--
+
+INSERT INTO `Orders` (`Order_Id`, `Account_Id`, `Order_Date`, `Order_CardType`, `Order_CardNumber`, `Order_CardExpiry`, `Order_Street`, `Order_City`, `Order_Province`, `Order_PostalCode`, `Order_FavouriteLineItem`) VALUES (1, 1, '2003-02-15 08:15:00', 'VISA', '999999999999', '05/03', '11 This Street', 'Victoria', 'BC', 'C4B 4F4', 2),
+(2, 4, '2003-02-15 08:15:00', 'MC', '888888888888', '06/03', '222 That Street', 'Edmonton', 'AB', 'X4K 5Y4', 1),
+(3, 3, '2003-02-15 08:15:00', 'AMEX', '777777777777', '07/03', '333 Other Street', 'Regina', 'SK', 'Z4U 6Y4', 2),
+(4, 2, '2003-02-15 08:15:00', 'MC', '666666666666', '08/03', '444 His Street', 'Toronto', 'ON', 'K4U 3S4', 1),
+(5, 5, '2003-02-15 08:15:00', 'VISA', '555555555555', '09/03', '555 Her Street', 'Calgary', 'AB', 'J4J 7S4', 2),
+(6, 5, '2003-02-15 08:15:00', 'VISA', '999999999999', '10/03', '6 Their Street', 'Victoria', 'BC', 'T4H 9G4', 1),
+(7, 4, '2003-02-15 08:15:00', 'MC', '888888888888', '11/03', '77 Lucky Street', 'Edmonton', 'AB', 'R4A 0Z4', 2),
+(8, 3, '2003-02-15 08:15:00', 'AMEX', '777777777777', '12/03', '888 Our Street', 'Regina', 'SK', 'S4S 7G4', 1),
+(9, 2, '2003-02-15 08:15:00', 'MC', '666666666666', '01/04', '999 Your Street', 'Toronto', 'ON', 'G4D 9F4', 2),
+(10, 1, '2003-02-15 08:15:00', 'VISA', '555555555555', '02/04', '99 Some Street', 'Calgary', 'AB', 'W4G 7A4', 1),
+(11, NULL, '2003-02-15 08:15:00', 'VISA', '555555555555', '02/04', 'Null order', 'Calgary', 'ZZ', 'XXX YYY', 1);
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `Others`
+--
+
+DROP TABLE IF EXISTS `Others`;
+CREATE TABLE `Others` (
+ `Other_Int` int(11) default NULL,
+ `Other_Long` bigint(20) default NULL,
+ `Other_Bit` bit(1) NOT NULL default '\0',
+ `Other_String` varchar(32) NOT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+--
+-- Dumping data for table `Others`
+--
+
+INSERT INTO `Others` (`Other_Int`, `Other_Long`, `Other_Bit`, `Other_String`) VALUES (1, 8888888, '\0', 'Oui'),
+(2, 9999999999, '', 'Non'),
+(99, 1966, '', 'Non');
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `Users`
+--
+
+DROP TABLE IF EXISTS `Users`;
+CREATE TABLE `Users` (
+ `LogonId` varchar(20) NOT NULL default '0',
+ `Name` varchar(40) default NULL,
+ `Password` varchar(20) default NULL,
+ `EmailAddress` varchar(40) default NULL,
+ `LastLogon` datetime default NULL,
+ PRIMARY KEY (`LogonId`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+--
+-- Dumping data for table `Users`
+--
+
+
+--
+-- Constraints for dumped tables
+--
+
+--
+-- Constraints for table `A`
+--
+ALTER TABLE `A`
+ ADD CONSTRAINT `FK_A_B` FOREIGN KEY (`B_ID`) REFERENCES `B` (`ID`),
+ ADD CONSTRAINT `FK_A_E` FOREIGN KEY (`E_ID`) REFERENCES `E` (`ID`),
+ ADD CONSTRAINT `FK_A_F` FOREIGN KEY (`F_ID`) REFERENCES `F` (`ID`);
+
+--
+-- Constraints for table `B`
+--
+ALTER TABLE `B`
+ ADD CONSTRAINT `FK_B_C` FOREIGN KEY (`C_ID`) REFERENCES `C` (`ID`),
+ ADD CONSTRAINT `FK_B_D` FOREIGN KEY (`D_ID`) REFERENCES `D` (`ID`);
diff --git a/tests/unit/Data/SqlMap/scripts/mysql/account-init.sql b/tests/unit/Data/SqlMap/scripts/mysql/account-init.sql
new file mode 100644
index 00000000..6b102597
--- /dev/null
+++ b/tests/unit/Data/SqlMap/scripts/mysql/account-init.sql
@@ -0,0 +1,7 @@
+TRUNCATE `Accounts`;
+
+INSERT INTO Accounts VALUES(1,'Joe', 'Dalton', 'Joe.Dalton@somewhere.com', 'Oui', 200);
+INSERT INTO Accounts VALUES(2,'Averel', 'Dalton', 'Averel.Dalton@somewhere.com', 'Oui', 200);
+INSERT INTO Accounts VALUES(3,'William', 'Dalton', null, 'Non', 100);
+INSERT INTO Accounts VALUES(4,'Jack', 'Dalton', 'Jack.Dalton@somewhere.com', 'Non', 100);
+INSERT INTO Accounts VALUES(5,'Gilles', 'Bayon', null, 'Oui', 100); \ No newline at end of file
diff --git a/tests/unit/Data/SqlMap/scripts/mysql/account-procedure.sql b/tests/unit/Data/SqlMap/scripts/mysql/account-procedure.sql
new file mode 100644
index 00000000..8b137891
--- /dev/null
+++ b/tests/unit/Data/SqlMap/scripts/mysql/account-procedure.sql
@@ -0,0 +1 @@
+
diff --git a/tests/unit/Data/SqlMap/scripts/mysql/category-init.sql b/tests/unit/Data/SqlMap/scripts/mysql/category-init.sql
new file mode 100644
index 00000000..0c2b447f
--- /dev/null
+++ b/tests/unit/Data/SqlMap/scripts/mysql/category-init.sql
@@ -0,0 +1 @@
+TRUNCATE `Categories`;
diff --git a/tests/unit/Data/SqlMap/scripts/mysql/category-procedure.sql b/tests/unit/Data/SqlMap/scripts/mysql/category-procedure.sql
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/tests/unit/Data/SqlMap/scripts/mysql/category-procedure.sql
diff --git a/tests/unit/Data/SqlMap/scripts/mysql/documents-init.sql b/tests/unit/Data/SqlMap/scripts/mysql/documents-init.sql
new file mode 100644
index 00000000..258ae532
--- /dev/null
+++ b/tests/unit/Data/SqlMap/scripts/mysql/documents-init.sql
@@ -0,0 +1,8 @@
+TRUNCATE `Documents`;
+
+INSERT INTO Documents VALUES (1, 'The World of Null-A', 'Book', 55, null);
+INSERT INTO Documents VALUES (2, 'Le Progres de Lyon', 'Newspaper', null , 'Lyon');
+INSERT INTO Documents VALUES (3, 'Lord of the Rings', 'Book', 3587, null);
+INSERT INTO Documents VALUES (4, 'Le Canard enchaine', 'Tabloid', null , 'Paris');
+INSERT INTO Documents VALUES (5, 'Le Monde', 'Broadsheet', null , 'Paris');
+INSERT INTO Documents VALUES (6, 'Foundation', 'Monograph', 557, null);
diff --git a/tests/unit/Data/SqlMap/scripts/mysql/enumeration-init.sql b/tests/unit/Data/SqlMap/scripts/mysql/enumeration-init.sql
new file mode 100644
index 00000000..4c0a7dee
--- /dev/null
+++ b/tests/unit/Data/SqlMap/scripts/mysql/enumeration-init.sql
@@ -0,0 +1,6 @@
+TRUNCATE `Enumerations`;
+
+INSERT INTO Enumerations VALUES(1, 1, 1, 128);
+INSERT INTO Enumerations VALUES(2, 2, 2, 2048);
+INSERT INTO Enumerations VALUES(3, 3, 4, 256);
+INSERT INTO Enumerations VALUES(4, 4, 8, null);
diff --git a/tests/unit/Data/SqlMap/scripts/mysql/line-item-init.sql b/tests/unit/Data/SqlMap/scripts/mysql/line-item-init.sql
new file mode 100644
index 00000000..9a96d525
--- /dev/null
+++ b/tests/unit/Data/SqlMap/scripts/mysql/line-item-init.sql
@@ -0,0 +1,24 @@
+
+TRUNCATE `LineItems`;
+
+INSERT INTO LineItems VALUES (1, 10, 'ESM-34', 1, 45.43, null);
+INSERT INTO LineItems VALUES (2, 10, 'QSM-98', 8, 8.40, null);
+INSERT INTO LineItems VALUES (1, 9, 'DSM-78', 2, 45.40, null);
+INSERT INTO LineItems VALUES (2, 9, 'TSM-12', 2, 32.12, null);
+INSERT INTO LineItems VALUES (1, 8, 'DSM-16', 4, 41.30, null);
+INSERT INTO LineItems VALUES (2, 8, 'GSM-65', 1, 2.20, null);
+INSERT INTO LineItems VALUES (1, 7, 'WSM-27', 7, 52.10, null);
+INSERT INTO LineItems VALUES (2, 7, 'ESM-23', 2, 123.34, null);
+INSERT INTO LineItems VALUES (1, 6, 'QSM-39', 9, 12.12, null);
+INSERT INTO LineItems VALUES (2, 6, 'ASM-45', 6, 78.77, null);
+INSERT INTO LineItems VALUES (1, 5, 'ESM-48', 3, 43.87, null);
+INSERT INTO LineItems VALUES (2, 5, 'WSM-98', 7, 5.40, null);
+INSERT INTO LineItems VALUES (1, 4, 'RSM-57', 2, 78.90, null);
+INSERT INTO LineItems VALUES (2, 4, 'XSM-78', 9, 2.34, null);
+INSERT INTO LineItems VALUES (1, 3, 'DSM-59', 3, 5.70, null);
+INSERT INTO LineItems VALUES (2, 3, 'DSM-53', 3, 98.78, null);
+INSERT INTO LineItems VALUES (1, 2, 'DSM-37', 4, 7.80, null);
+INSERT INTO LineItems VALUES (2, 2, 'FSM-12', 2, 55.78, null);
+INSERT INTO LineItems VALUES (1, 1, 'ESM-48', 8, 87.60, null);
+INSERT INTO LineItems VALUES (2, 1, 'ESM-23', 1, 55.40, null);
+
diff --git a/tests/unit/Data/SqlMap/scripts/mysql/more-account-records.sql b/tests/unit/Data/SqlMap/scripts/mysql/more-account-records.sql
new file mode 100644
index 00000000..de33a256
--- /dev/null
+++ b/tests/unit/Data/SqlMap/scripts/mysql/more-account-records.sql
@@ -0,0 +1,7 @@
+
+INSERT INTO Accounts VALUES(6,'Jane', 'Calamity', 'Jane.Calamity@somewhere.com', 'Oui', 200);
+INSERT INTO Accounts VALUES(7,'Lucky', 'Luke', 'Lucky.Luke@somewhere.com', 'Oui', 200);
+INSERT INTO Accounts VALUES(8,'Ming', 'Li Foo', null, 'Non', 100);
+INSERT INTO Accounts VALUES(9,'O''Hara', 'Steve', 'Jack.OHara@somewhere.com', 'Oui', 200);
+INSERT INTO Accounts VALUES(10,'Robert', 'O''Timmins', null, 'Non', 100);
+
diff --git a/tests/unit/Data/SqlMap/scripts/mysql/order-init.sql b/tests/unit/Data/SqlMap/scripts/mysql/order-init.sql
new file mode 100644
index 00000000..2af33cb2
--- /dev/null
+++ b/tests/unit/Data/SqlMap/scripts/mysql/order-init.sql
@@ -0,0 +1,15 @@
+TRUNCATE `Orders`;
+
+
+INSERT INTO Orders VALUES (1, 1, '2003-02-15 8:15:00', 'VISA', '999999999999', '05/03', '11 This Street', 'Victoria', 'BC', 'C4B 4F4',2);
+INSERT INTO Orders VALUES (2, 4, '2003-02-15 8:15:00', 'MC', '888888888888', '06/03', '222 That Street', 'Edmonton', 'AB', 'X4K 5Y4',1);
+INSERT INTO Orders VALUES (3, 3, '2003-02-15 8:15:00', 'AMEX', '777777777777', '07/03', '333 Other Street', 'Regina', 'SK', 'Z4U 6Y4',2);
+INSERT INTO Orders VALUES (4, 2, '2003-02-15 8:15:00', 'MC', '666666666666', '08/03', '444 His Street', 'Toronto', 'ON', 'K4U 3S4',1);
+INSERT INTO Orders VALUES (5, 5, '2003-02-15 8:15:00', 'VISA', '555555555555', '09/03', '555 Her Street', 'Calgary', 'AB', 'J4J 7S4',2);
+INSERT INTO Orders VALUES (6, 5, '2003-02-15 8:15:00', 'VISA', '999999999999', '10/03', '6 Their Street', 'Victoria', 'BC', 'T4H 9G4',1);
+INSERT INTO Orders VALUES (7, 4, '2003-02-15 8:15:00', 'MC', '888888888888', '11/03', '77 Lucky Street', 'Edmonton', 'AB', 'R4A 0Z4',2);
+INSERT INTO Orders VALUES (8, 3, '2003-02-15 8:15:00', 'AMEX', '777777777777', '12/03', '888 Our Street', 'Regina', 'SK', 'S4S 7G4',1);
+INSERT INTO Orders VALUES (9, 2, '2003-02-15 8:15:00', 'MC', '666666666666', '01/04', '999 Your Street', 'Toronto', 'ON', 'G4D 9F4',2);
+INSERT INTO Orders VALUES (10, 1, '2003-02-15 8:15:00', 'VISA', '555555555555', '02/04', '99 Some Street', 'Calgary', 'AB', 'W4G 7A4',1);
+INSERT INTO Orders VALUES (11, null, '2003-02-15 8:15:00', 'VISA', '555555555555', '02/04', 'Null order', 'Calgary', 'ZZ', 'XXX YYY',1);
+
diff --git a/tests/unit/Data/SqlMap/scripts/mysql/other-init.sql b/tests/unit/Data/SqlMap/scripts/mysql/other-init.sql
new file mode 100644
index 00000000..409de6d3
--- /dev/null
+++ b/tests/unit/Data/SqlMap/scripts/mysql/other-init.sql
@@ -0,0 +1,18 @@
+
+TRUNCATE `Others`;
+TRUNCATE `A`;
+TRUNCATE `B`;
+TRUNCATE `C`;
+TRUNCATE `D`;
+TRUNCATE `E`;
+TRUNCATE `F`;
+
+INSERT INTO Others VALUES(1, 8888888, 0, 'Oui');
+INSERT INTO Others VALUES(2, 9999999999, 1, 'Non');
+
+INSERT INTO F VALUES('f', 'fff');
+INSERT INTO E VALUES('e', 'eee');
+INSERT INTO D VALUES('d', 'ddd');
+INSERT INTO C VALUES('c', 'ccc');
+INSERT INTO B VALUES('b', 'c', null, 'bbb');
+INSERT INTO A VALUES('a', 'b', 'e', null, 'aaa'); \ No newline at end of file
diff --git a/tests/unit/Data/SqlMap/scripts/mysql/swap-procedure.sql b/tests/unit/Data/SqlMap/scripts/mysql/swap-procedure.sql
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/tests/unit/Data/SqlMap/scripts/mysql/swap-procedure.sql
diff --git a/tests/unit/Data/SqlMap/scripts/mysql/user-init.sql b/tests/unit/Data/SqlMap/scripts/mysql/user-init.sql
new file mode 100644
index 00000000..fe9c0c67
--- /dev/null
+++ b/tests/unit/Data/SqlMap/scripts/mysql/user-init.sql
@@ -0,0 +1,2 @@
+
+TRUNCATE `users`;
diff --git a/tests/unit/Data/SqlMap/scripts/sqlite/database.sql b/tests/unit/Data/SqlMap/scripts/sqlite/database.sql
new file mode 100644
index 00000000..6bef6f4c
--- /dev/null
+++ b/tests/unit/Data/SqlMap/scripts/sqlite/database.sql
@@ -0,0 +1,242 @@
+#
+# : A
+#
+DROP TABLE A;
+
+CREATE TABLE A
+(
+ ID VARCHAR(50) NOT NULL PRIMARY KEY,
+ B_ID VARCHAR(50),
+ E_ID VARCHAR(50),
+ F_ID VARCHAR(50),
+ A_Libelle VARCHAR(50)
+);
+
+INSERT INTO A VALUES ('a', 'b', 'e', NULL, 'aaa');
+
+
+#
+# : Accounts
+#
+DROP TABLE Accounts;
+CREATE TABLE Accounts
+(
+ Account_Id INTEGER NOT NULL PRIMARY KEY,
+ Account_FirstName VARCHAR(32) NOT NULL,
+ Account_LastName VARCHAR(32) NOT NULL,
+ Account_Email VARCHAR(128),
+ Account_Banner_Option VARCHAR(255),
+ Account_Cart_Option INT
+);
+
+INSERT INTO Accounts VALUES ('1', 'Joe', 'Dalton', 'Joe.Dalton@somewhere.com', 'Oui', '200');
+INSERT INTO Accounts VALUES ('2', 'Averel', 'Dalton', 'Averel.Dalton@somewhere.com', 'Oui', '200');
+INSERT INTO Accounts VALUES ('3', 'William', 'Dalton', NULL, 'Non', '100');
+INSERT INTO Accounts VALUES ('4', 'Jack', 'Dalton', 'Jack.Dalton@somewhere.com', 'Non', '100');
+INSERT INTO Accounts VALUES ('5', 'Gilles', 'Bayon', NULL, 'Oui', '100');
+
+
+#
+# : B
+#
+DROP TABLE B;
+CREATE TABLE B
+(
+ ID VARCHAR(50) NOT NULL PRIMARY KEY,
+ C_ID VARCHAR(50),
+ D_ID VARCHAR(50),
+ B_Libelle VARCHAR(50)
+);
+
+INSERT INTO B VALUES ('b', 'c', NULL, 'bbb');
+
+
+#
+# : C
+#
+DROP TABLE C;
+CREATE TABLE C
+(
+ ID VARCHAR(50) NOT NULL PRIMARY KEY,
+ C_Libelle VARCHAR(50)
+);
+
+INSERT INTO C VALUES ('c', 'ccc');
+
+
+#
+# : Categories
+#
+DROP TABLE Categories;
+create table Categories
+(
+ Category_Id INTEGER NOT NULL PRIMARY KEY,
+ Category_Name varchar(32),
+ Category_Guid varchar(36)
+);
+
+
+#
+# : D
+#
+DROP TABLE D;
+CREATE TABLE D
+(
+ ID VARCHAR(50) NOT NULL PRIMARY KEY,
+ D_Libelle VARCHAR(50)
+);
+
+INSERT INTO D VALUES ('d', 'ddd');
+
+
+#
+# : Documents
+#
+DROP TABLE Documents;
+CREATE TABLE Documents
+(
+ Document_Id INT NOT NULL PRIMARY KEY,
+ Document_Title VARCHAR(32),
+ Document_Type VARCHAR(32),
+ Document_PageNumber INT,
+ Document_City VARCHAR(32)
+);
+
+INSERT INTO Documents VALUES ('1', 'The World of Null-A', 'Book', '55', NULL);
+INSERT INTO Documents VALUES ('2', 'Le Progres de Lyon', 'Newspaper', NULL, 'Lyon');
+INSERT INTO Documents VALUES ('3', 'Lord of the Rings', 'Book', '3587', NULL);
+INSERT INTO Documents VALUES ('4', 'Le Canard enchaine', 'Tabloid', NULL, 'Paris');
+INSERT INTO Documents VALUES ('5', 'Le Monde', 'Broadsheet', NULL, 'Paris');
+INSERT INTO Documents VALUES ('6', 'Foundation', 'Monograph', '557', NULL);
+
+
+#
+# : E
+#
+DROP TABLE E;
+CREATE TABLE E
+(
+ ID VARCHAR(50) NOT NULL PRIMARY KEY,
+ E_Libelle VARCHAR(50)
+);
+
+
+INSERT INTO E VALUES ('e', 'eee');
+
+
+#
+# : Enumerations
+#
+DROP TABLE Enumerations;
+create table Enumerations
+(
+ Enum_Id int not null,
+ Enum_Day int not null,
+ Enum_Color int not null,
+ Enum_Month int
+);
+
+
+INSERT INTO Enumerations VALUES ('1', '1', '1', '128');
+INSERT INTO Enumerations VALUES ('2', '2', '2', '2048');
+INSERT INTO Enumerations VALUES ('3', '3', '4', '256');
+INSERT INTO Enumerations VALUES ('4', '4', '8', NULL);
+
+
+#
+# : F
+#
+DROP TABLE F;
+CREATE TABLE F
+(
+ ID VARCHAR(50) NOT NULL PRIMARY KEY,
+ F_Libelle VARCHAR(50)
+);
+
+INSERT INTO F VALUES ('f', 'fff');
+
+
+#
+# : LineItems
+#
+DROP TABLE LineItems;
+CREATE TABLE LineItems
+(
+ LineItem_Id INTEGER NOT NULL,
+ Order_Id INT NOT NULL,
+ LineItem_Code VARCHAR(32) NOT NULL,
+ LineItem_Quantity INT NOT NULL,
+ LineItem_Price DECIMAL(18,2),
+ LineItem_Picture BLOB
+);
+
+
+INSERT INTO LineItems VALUES ('1', '10', 'ESM-34', '1', '45.43', NULL);
+INSERT INTO LineItems VALUES ('2', '10', 'QSM-98', '8', '8.40', NULL);
+INSERT INTO LineItems VALUES ('1', '9', 'DSM-78', '2', '45.40', NULL);
+INSERT INTO LineItems VALUES ('2', '9', 'TSM-12', '2', '32.12', NULL);
+INSERT INTO LineItems VALUES ('1', '8', 'DSM-16', '4', '41.30', NULL);
+INSERT INTO LineItems VALUES ('2', '8', 'GSM-65', '1', '2.20', NULL);
+INSERT INTO LineItems VALUES ('1', '7', 'WSM-27', '7', '52.10', NULL);
+INSERT INTO LineItems VALUES ('2', '7', 'ESM-23', '2', '123.34', NULL);
+INSERT INTO LineItems VALUES ('1', '6', 'QSM-39', '9', '12.12', NULL);
+INSERT INTO LineItems VALUES ('2', '6', 'ASM-45', '6', '78.77', NULL);
+INSERT INTO LineItems VALUES ('1', '5', 'ESM-48', '3', '43.87', NULL);
+INSERT INTO LineItems VALUES ('2', '5', 'WSM-98', '7', '5.40', NULL);
+INSERT INTO LineItems VALUES ('1', '4', 'RSM-57', '2', '78.90', NULL);
+INSERT INTO LineItems VALUES ('2', '4', 'XSM-78', '9', '2.34', NULL);
+INSERT INTO LineItems VALUES ('1', '3', 'DSM-59', '3', '5.70', NULL);
+INSERT INTO LineItems VALUES ('2', '3', 'DSM-53', '3', '98.78', NULL);
+INSERT INTO LineItems VALUES ('1', '2', 'DSM-37', '4', '7.80', NULL);
+INSERT INTO LineItems VALUES ('2', '2', 'FSM-12', '2', '55.78', NULL);
+INSERT INTO LineItems VALUES ('1', '1', 'ESM-48', '8', '87.60', NULL);
+INSERT INTO LineItems VALUES ('2', '1', 'ESM-23', '1', '55.40', NULL);
+
+
+#
+# : Orders
+#
+DROP TABLE Orders;
+CREATE TABLE Orders
+(
+ Order_Id INTEGER NOT NULL PRIMARY KEY,
+ Account_Id INT,
+ Order_Date DATETIME,
+ Order_CardType VARCHAR(32),
+ Order_CardNumber VARCHAR(32),
+ Order_CardExpiry VARCHAR(32),
+ Order_Street VARCHAR(32),
+ Order_City VARCHAR(32),
+ Order_Province VARCHAR(32),
+ Order_PostalCode VARCHAR(32),
+ Order_FavouriteLineItem INT
+);
+
+INSERT INTO Orders VALUES ('1', '1', '2003-02-15 8:15:00', 'VISA', '999999999999', '05/03', '11 This Street', 'Victoria', 'BC', 'C4B 4F4', '2');
+INSERT INTO Orders VALUES ('2', '4', '2003-02-15 8:15:00', 'MC', '888888888888', '06/03', '222 That Street', 'Edmonton', 'AB', 'X4K 5Y4', '1');
+INSERT INTO Orders VALUES ('3', '3', '2003-02-15 8:15:00', 'AMEX', '777777777777', '07/03', '333 Other Street', 'Regina', 'SK', 'Z4U 6Y4', '2');
+INSERT INTO Orders VALUES ('4', '2', '2003-02-15 8:15:00', 'MC', '666666666666', '08/03', '444 His Street', 'Toronto', 'ON', 'K4U 3S4', '1');
+INSERT INTO Orders VALUES ('5', '5', '2003-02-15 8:15:00', 'VISA', '555555555555', '09/03', '555 Her Street', 'Calgary', 'AB', 'J4J 7S4', '2');
+INSERT INTO Orders VALUES ('6', '5', '2003-02-15 8:15:00', 'VISA', '999999999999', '10/03', '6 Their Street', 'Victoria', 'BC', 'T4H 9G4', '1');
+INSERT INTO Orders VALUES ('7', '4', '2003-02-15 8:15:00', 'MC', '888888888888', '11/03', '77 Lucky Street', 'Edmonton', 'AB', 'R4A 0Z4', '2');
+INSERT INTO Orders VALUES ('8', '3', '2003-02-15 8:15:00', 'AMEX', '777777777777', '12/03', '888 Our Street', 'Regina', 'SK', 'S4S 7G4', '1');
+INSERT INTO Orders VALUES ('9', '2', '2003-02-15 8:15:00', 'MC', '666666666666', '01/04', '999 Your Street', 'Toronto', 'ON', 'G4D 9F4', '2');
+INSERT INTO Orders VALUES ('10', '1', '2003-02-15 8:15:00', 'VISA', '555555555555', '02/04', '99 Some Street', 'Calgary', 'AB', 'W4G 7A4', '1');
+INSERT INTO Orders VALUES ('11', NULL, '2003-02-15 8:15:00', 'VISA', '555555555555', '02/04', 'Null order', 'Calgary', 'ZZ', 'XXX YYY', '1');
+
+
+#
+# : Others
+#
+DROP TABLE Others;
+create table Others
+(
+ Other_Int int,
+ Other_Long bigint,
+ Other_Bit bit not null default 0,
+ Other_String varchar(32) not null
+);
+
+INSERT INTO Others VALUES ('1', '8888888', '0', 'Oui');
+INSERT INTO Others VALUES ('2', '9999999999', '1', 'Non');
+
diff --git a/tests/unit/Data/SqlMap/sqlite.xml b/tests/unit/Data/SqlMap/sqlite.xml
new file mode 100644
index 00000000..ea5f3356
--- /dev/null
+++ b/tests/unit/Data/SqlMap/sqlite.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<sqlMapConfig>
+
+ <!-- properties that replaces instanceof $name$ in the sqlmap files -->
+ <properties>
+ <property name="selectKey" value="select @@IDENTITY as value" />
+ <property name="MyCategoryName" value="'Film'" />
+ <property name="accountName" value="'Joe'" />
+ </properties>
+
+ <!-- type handlers -->
+ <typeHandlers>
+ <typeHandler class="OuiNonBool" dbType="Varchar" />
+ </typeHandlers>
+
+ <!-- sqlmap configurations -->
+ <sqlMaps>
+ <sqlMap resource="maps/sqlite/Account.xml"/>
+ <sqlMap resource="maps/sqlite/DynamicAccount.xml"/>
+ <sqlMap resource="maps/sqlite/Order.xml"/>
+ <sqlMap resource="maps/sqlite/Category.xml"/>
+ <sqlMap resource="maps/sqlite/Complex.xml"/>
+ <sqlMap resource="maps/sqlite/LineItem.xml"/>
+ <sqlMap resource="maps/sqlite/Enumeration.xml"/>
+ <sqlMap resource="maps/sqlite/Other.xml"/>
+ <sqlMap resource="maps/sqlite/ResultClass.xml"/>
+ <sqlMap resource="maps/sqlite/Document.xml"/>
+ <sqlMap resource="maps/sqlite/ActiveRecord.xml"/>
+ </sqlMaps>
+
+</sqlMapConfig> \ No newline at end of file
diff --git a/tests/unit/Data/SqlMap/sqlite/backup.db b/tests/unit/Data/SqlMap/sqlite/backup.db
new file mode 100644
index 00000000..4f5a353d
--- /dev/null
+++ b/tests/unit/Data/SqlMap/sqlite/backup.db
Binary files differ
diff --git a/tests/unit/Data/SqlMap/sqlite/tests.db b/tests/unit/Data/SqlMap/sqlite/tests.db
new file mode 100644
index 00000000..eabfcab5
--- /dev/null
+++ b/tests/unit/Data/SqlMap/sqlite/tests.db
Binary files differ
diff --git a/tests/unit/Data/SqlMap/sqlmap.xml b/tests/unit/Data/SqlMap/sqlmap.xml
new file mode 100644
index 00000000..e6877f16
--- /dev/null
+++ b/tests/unit/Data/SqlMap/sqlmap.xml
@@ -0,0 +1,21 @@
+<sqlmap>
+
+ <statement
+ id="findNotVisitedWatchedTopicList"
+ resultClass="TopicRecord"
+ parametrClass="array"
+ >
+ <![CDATA[
+ SELECT rt.*
+ FROM rbx_watched_topic as rwt
+ LEFT JOIN rbx_topic as rt
+ ON rwt.topic_id = rt.topic_id
+ WHERE user_id = #user_id# AND
+ ( rt.created > #last_visit# OR
+ rt.modified > #last_visit# OR
+ rwt.visited = 0 )
+ ORDER BY rt.title ASC
+ ]]>
+ </statement>
+
+</sqlmap> \ No newline at end of file
diff --git a/tests/unit/Data/TableGateway/BaseGatewayTest.php b/tests/unit/Data/TableGateway/BaseGatewayTest.php
new file mode 100644
index 00000000..b97ef4a0
--- /dev/null
+++ b/tests/unit/Data/TableGateway/BaseGatewayTest.php
@@ -0,0 +1,96 @@
+<?php
+Prado::using('System.Data.*');
+Prado::using('System.Data.DataGateway.TTableGateway');
+
+/**
+ * @package System.Data.TableGateway
+ */
+class BaseGatewayTest extends PHPUnit_Framework_TestCase
+{
+ protected $gateway1;
+ protected $gateway2;
+
+ /**
+ * @return TTableGateway
+ */
+ function getGateway()
+ {
+ if($this->gateway1===null)
+ {
+ $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test');
+ $this->gateway1 = new TTableGateway('address', $conn);
+ }
+ return $this->gateway1;
+ }
+
+ /**
+ * @return TTableGateway
+ */
+ function getGateway2()
+ {
+ if($this->gateway2===null)
+ {
+ $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test');
+ $this->gateway2 = new TTableGateway('department_sections', $conn);
+ }
+ return $this->gateway2;
+ }
+
+ function setup()
+ {
+ $this->delete_all();
+ }
+
+ function add_record1()
+ {
+ $result = $this->getGateway()->insert($this->get_record1());
+ $this->assertTrue(intval($result) > 0);
+ }
+ function add_record2()
+ {
+ $result = $this->getGateway()->insert($this->get_record2());
+ $this->assertTrue(intval($result) > 0);
+ }
+ function get_record1()
+ {
+ return array(
+ 'username' => 'Username',
+ 'phone' => 121987,
+ 'field1_boolean' => true,
+ 'field2_date' => '2007-12-25',
+ 'field3_double' => 121.1,
+ 'field4_integer' => 3,
+ 'field5_text' => 'asdasd',
+ 'field6_time' => '12:40:00',
+ 'field7_timestamp' => 'NOW',
+ 'field8_money' => '$121.12',
+ 'field9_numeric' => 98.2232,
+ 'int_fk1'=>1,
+ 'int_fk2'=>1,
+ );
+ }
+
+
+ function get_record2()
+ {
+ return array(
+ 'username' => 'record2',
+ 'phone' => 45233,
+ 'field1_boolean' => false,
+ 'field2_date' => '2004-10-05',
+ 'field3_double' => 1221.1,
+ 'field4_integer' => 2,
+ 'field5_text' => 'hello world',
+ 'field6_time' => '22:40:00',
+ 'field7_timestamp' => 'NOW',
+ 'field8_money' => '$1121.12',
+ 'field9_numeric' => 8.2213,
+ 'int_fk1'=>1,
+ 'int_fk2'=>1,
+ );
+ }
+ function delete_all()
+ {
+ $this->getGateway()->deleteAll('1=1');
+ }
+} \ No newline at end of file
diff --git a/tests/unit/Data/TableGateway/CountTest.php b/tests/unit/Data/TableGateway/CountTest.php
new file mode 100644
index 00000000..074d935b
--- /dev/null
+++ b/tests/unit/Data/TableGateway/CountTest.php
@@ -0,0 +1,18 @@
+<?php
+
+require_once(dirname(__FILE__).'/BaseGatewayTest.php');
+
+/**
+ * @package System.Data.TableGateway
+ */
+class CountTest extends BaseGatewayTest
+{
+ function test_simple_count()
+ {
+ $result = $this->getGateway2()->count();
+ $this->assertEqual(44,$result);
+
+ $result = $this->getGateway2()->count('department_id = ?', 1);
+ $this->assertEqual(4, $result);
+ }
+} \ No newline at end of file
diff --git a/tests/unit/Data/TableGateway/MagicCallTest.php b/tests/unit/Data/TableGateway/MagicCallTest.php
new file mode 100644
index 00000000..56cc85b3
--- /dev/null
+++ b/tests/unit/Data/TableGateway/MagicCallTest.php
@@ -0,0 +1,33 @@
+<?php
+
+require_once(dirname(__FILE__).'/BaseGatewayTest.php');
+
+/**
+ * @package System.Data.TableGateway
+ */
+class MagicCallTest extends BaseGatewayTest
+{
+ function test_magic_call()
+ {
+ $this->add_record1(); $this->add_record2();
+
+ $result = $this->getGateway()->findByUsername("record2");
+ $this->assertEqual($result['username'], 'record2');
+ }
+
+ function test_combined_and_or()
+ {
+ $this->add_record1(); $this->add_record2();
+
+ $result = $this->getGateway()->findAllByUsername_OR_phone('Username', '45233')->readAll();
+ $this->assertEqual(2, count($result));
+ }
+
+ function test_no_result()
+ {
+ $this->add_record1(); $this->add_record2();
+ $result = $this->getGateway()->findAllByUsername_and_phone('Username', '45233')->readAll();
+
+ $this->assertEqual(0, count($result));
+ }
+} \ No newline at end of file
diff --git a/tests/unit/Data/TableGateway/TableGatewayDeleteByPkTest.php b/tests/unit/Data/TableGateway/TableGatewayDeleteByPkTest.php
new file mode 100644
index 00000000..6bcaeb91
--- /dev/null
+++ b/tests/unit/Data/TableGateway/TableGatewayDeleteByPkTest.php
@@ -0,0 +1,54 @@
+<?php
+
+require_once(dirname(__FILE__).'/BaseGatewayTest.php');
+
+/**
+ * @package System.Data.TableGateway
+ */
+class TableGatewayDeleteByPkTest extends BaseGatewayTest
+{
+ function test_delete_by_1_pk()
+ {
+ $this->add_record1();
+ $id = $this->getGateway()->getLastInsertId();
+ $deleted = $this->getGateway()->deleteByPk($id);
+
+ $this->assertEqual(1, $deleted);
+ }
+
+ function test_delete_by_multiple_pk()
+ {
+ $this->add_record1();
+ $id1 = $this->getGateway()->getLastInsertId();
+ $this->add_record2();
+ $id2 = $this->getGateway()->getLastInsertId();
+
+ $deleted = $this->getGateway()->deleteByPk($id1, $id2);
+
+ $this->assertEqual(2, $deleted);
+ }
+
+ function test_delete_by_multiple_pk2()
+ {
+ $this->add_record1();
+ $id1 = $this->getGateway()->getLastInsertId();
+ $this->add_record2();
+ $id2 = $this->getGateway()->getLastInsertId();
+
+ $deleted = $this->getGateway()->deleteByPk(array($id1, $id2));
+
+ $this->assertEqual(2, $deleted);
+ }
+
+ function test_delete_by_multiple_pk3()
+ {
+ $this->add_record1();
+ $id1 = $this->getGateway()->getLastInsertId();
+ $this->add_record2();
+ $id2 = $this->getGateway()->getLastInsertId();
+
+ $deleted = $this->getGateway()->deleteByPk(array(array($id1), array($id2)));
+
+ $this->assertEqual(2, $deleted);
+ }
+} \ No newline at end of file
diff --git a/tests/unit/Data/TableGateway/TableGatewayPgsqlTest.php b/tests/unit/Data/TableGateway/TableGatewayPgsqlTest.php
new file mode 100644
index 00000000..234f70bd
--- /dev/null
+++ b/tests/unit/Data/TableGateway/TableGatewayPgsqlTest.php
@@ -0,0 +1,58 @@
+<?php
+require_once(dirname(__FILE__).'/BaseGatewayTest.php');
+
+/**
+ * @package System.Data.TableGateway
+ */
+class TableGatewayPgsqlTest extends BaseGatewayTest
+{
+
+ function test_update()
+ {
+ $this->add_record1();
+ $address = array('username' => 'tester 1', 'field5_text'=>null);
+ $result = $this->getGateway()->update($address, 'username = ?', 'Username');
+ $this->assertTrue($result);
+
+ $test = $this->getGateway()->find('username = ?', 'tester 1');
+ unset($test['id']);
+ $expect = $this->get_record1();
+ $expect['username'] = 'tester 1';
+ $expect['field5_text'] = null;
+ unset($expect['field7_timestamp']); unset($test['field7_timestamp']);
+ $this->assertEqual($expect, $test);
+
+ $this->assertTrue($this->getGateway()->deleteAll('username = ?', 'tester 1'));
+ }
+
+ function test_update_named()
+ {
+ $this->add_record1();
+ $address = array('username' => 'tester 1', 'field5_text'=>null);
+ $result = $this->getGateway()->update($address, 'username = :name', array(':name'=>'Username'));
+ $this->assertTrue($result);
+
+ $test = $this->getGateway()->find('username = :name', array(':name'=>'tester 1'));
+ unset($test['id']);
+ $expect = $this->get_record1();
+ $expect['username'] = 'tester 1';
+ $expect['field5_text'] = null;
+ unset($expect['field7_timestamp']); unset($test['field7_timestamp']);
+ $this->assertEqual($expect, $test);
+
+ $this->assertTrue($this->getGateway()->deleteAll('username = :name', array(':name'=>'tester 1')));
+ }
+
+ function test_find_all()
+ {
+ $this->add_record1();
+ $this->add_record2();
+
+ $results = $this->getGateway()->findAll('true')->readAll();
+ $this->assertEqual(count($results), 2);
+
+ $result = $this->getGateway()->findAllBySql('SELECT username FROM address WHERE phone = ?', '45233')->read();
+ $this->assertEqual($result['username'], 'record2');
+ }
+
+} \ No newline at end of file
diff --git a/tests/unit/Data/TableGateway/TableInfoGatewayTest.php b/tests/unit/Data/TableGateway/TableInfoGatewayTest.php
new file mode 100644
index 00000000..24b94690
--- /dev/null
+++ b/tests/unit/Data/TableGateway/TableInfoGatewayTest.php
@@ -0,0 +1,19 @@
+<?php
+
+require_once(dirname(__FILE__).'/BaseGatewayTest.php');
+
+/**
+ * @package System.Data.TableGateway
+ */
+class TableInfoGatewayTest extends BaseGatewayTest
+{
+ function test_table_info()
+ {
+ $conn = $this->getGateway()->getDbConnection();
+ $this->add_record1();
+ $this->add_record2();
+ $info = TDbMetaData::getInstance($conn)->getTableInfo('address');
+ $table = new TTableGateway($info, $conn);
+ $this->assertEqual(count($table->findAll()->readAll()), 2);
+ }
+} \ No newline at end of file
diff --git a/tests/unit/Data/TableGateway/TestFindByPk.php b/tests/unit/Data/TableGateway/TestFindByPk.php
new file mode 100644
index 00000000..f23fafa7
--- /dev/null
+++ b/tests/unit/Data/TableGateway/TestFindByPk.php
@@ -0,0 +1,50 @@
+<?php
+
+require_once(dirname(__FILE__).'/BaseGatewayTest.php');
+
+/**
+ * @package System.Data.TableGateway
+ */
+class TestFindByPk extends BaseGatewayTest
+{
+ function test_one_key()
+ {
+ $this->add_record1();
+ $id = $this->getGateway()->getLastInsertId();
+ $result = $this->getGateway()->findByPk($id);
+
+ $record1 = $this->get_record1();
+
+ //clean and ignore some fields
+ unset($result['id']);
+ unset($result['field7_timestamp']);
+ unset($record1['field7_timestamp']);
+ $result['phone'] = intval($result['phone']);
+ $result['field9_numeric'] = floatval($result['field9_numeric']);
+
+ $this->assertEqual($record1, $result);
+ }
+
+ function test_composite_key()
+ {
+ $gateway = $this->getGateway2();
+
+ $result = $gateway->findByPk(1,1);
+ $expect = array("department_id" => 1, "section_id" => 1, "order" => 0);
+ $this->assertEqual($expect, $result);
+ }
+
+ function test_find_all_keys()
+ {
+ $gateway = $this->getGateway2();
+
+ $result = $gateway->findAllByPks(array(1,1), array(3,13))->readAll();
+
+ $expect = array(
+ array("department_id" => 1, "section_id" => 1, "order" => 0),
+ array("department_id" => 3, "section_id" => 13, "order" => 0));
+
+ $this->assertEqual($expect, $result);
+
+ }
+} \ No newline at end of file