diff options
author | wei <> | 2006-12-20 03:15:04 +0000 |
---|---|---|
committer | wei <> | 2006-12-20 03:15:04 +0000 |
commit | 2c221ea67d0512961beea8fbcb30b23865c16bb0 (patch) | |
tree | aba7901f8e286d0b4101fc9022247897881bd5c1 /tests/simple_unit | |
parent | 2570226fbac3e26b1e94896b50d1db4bc1aa3308 (diff) |
Add quickstart docs for Active Record and SqlMap
Diffstat (limited to 'tests/simple_unit')
21 files changed, 434 insertions, 446 deletions
diff --git a/tests/simple_unit/SqlMap/ActiveRecordSqlMapTest.php b/tests/simple_unit/SqlMap/ActiveRecordSqlMapTest.php index 107985db..9dc944f5 100644 --- a/tests/simple_unit/SqlMap/ActiveRecordSqlMapTest.php +++ b/tests/simple_unit/SqlMap/ActiveRecordSqlMapTest.php @@ -1,4 +1,4 @@ -<?php +<?php
require_once(dirname(__FILE__).'/BaseCase.php');
@@ -14,7 +14,7 @@ class ActiveAccount extends TActiveRecord public $Account_Banner_Option;
public $Account_Cart_Option;
- private static $_tablename='accounts';
+ private static $_tablename='Accounts';
public static function finder()
{
@@ -81,5 +81,5 @@ class ActiveRecordSqlMapTest extends BaseCase $this->assertEqual($account1->{$prop}, $account2->{$prop});
}
}
- +
?>
\ No newline at end of file diff --git a/tests/simple_unit/SqlMap/InheritanceTest.php b/tests/simple_unit/SqlMap/InheritanceTest.php index 38542516..b0dd2dc9 100644 --- a/tests/simple_unit/SqlMap/InheritanceTest.php +++ b/tests/simple_unit/SqlMap/InheritanceTest.php @@ -20,7 +20,7 @@ class InheritanceTest extends BaseCase {
$list = $this->sqlmap->queryForList("GetAllDocument");
- $this->assertIdentical(6, count($list));
+ $this->assertEqual(6, count($list));
$book = $list[0];
$this->assertBook($book, 1, "The World of Null-A", 55);
@@ -45,7 +45,7 @@ class InheritanceTest extends BaseCase {
$list = $this->sqlmap->queryForList("GetTypedCollection");
- $this->assertIdentical(6, $list->getCount());
+ $this->assertEqual(6, $list->getCount());
$book = $list[0];
$this->assertBook($book, 1, "The World of Null-A", 55);
@@ -75,7 +75,7 @@ class InheritanceTest extends BaseCase $list = $this->sqlmap->queryForList("GetAllDocumentWithCustomTypeHandler");
- $this->assertIdentical(6, count($list));
+ $this->assertEqual(6, count($list));
$book = $list[0];
$this->assertBook($book, 1, "The World of Null-A", 55);
@@ -97,22 +97,22 @@ class InheritanceTest extends BaseCase function AssertDocument(Document $document, $id, $title)
{
- $this->assertIdentical($id, $document->getID());
- $this->assertIdentical($title, $document->getTitle());
+ $this->assertEqual($id, $document->getID());
+ $this->assertEqual($title, $document->getTitle());
}
function AssertBook(Book $book, $id, $title, $pageNumber)
{
- $this->assertIdentical($id, $book->getId());
- $this->assertIdentical($title, $book->getTitle());
- $this->assertIdentical($pageNumber, (int)$book->getPageNumber());
+ $this->assertEqual($id, $book->getId());
+ $this->assertEqual($title, $book->getTitle());
+ $this->assertEqual($pageNumber, (int)$book->getPageNumber());
}
function AssertNewspaper(Newspaper $news, $id, $title, $city)
{
- $this->assertIdentical($id, $news->getId());
- $this->assertIdentical($title, $news->getTitle());
- $this->assertIdentical($city, $news->getCity());
+ $this->assertEqual($id, $news->getId());
+ $this->assertEqual($title, $news->getTitle());
+ $this->assertEqual($city, $news->getCity());
}
}
diff --git a/tests/simple_unit/SqlMap/StatementTest.php b/tests/simple_unit/SqlMap/StatementTest.php index 671cae77..3ac0a3ab 100644 --- a/tests/simple_unit/SqlMap/StatementTest.php +++ b/tests/simple_unit/SqlMap/StatementTest.php @@ -41,8 +41,7 @@ class StatementTest extends BaseCase */
function testOpenConnection()
{
- $conn = $this->getConnection();
- $this->sqlmap->setDbConnection($conn);
+ $conn = $this->sqlmap->getDbConnection();
$conn->setActive(true);
$account= $this->sqlmap->QueryForObject("SelectWithProperty");
$conn->setActive(false);
@@ -644,7 +643,7 @@ class StatementTest extends BaseCase */
function testExecuteQueryForWithComplexJoined()
{
- $a = $this->sqlmap->QueryForObject("SelectComplexJoined",null);
+ $a = $this->sqlmap->QueryForObject("SelectComplexJoined");
$this->assertNotNull($a);
$this->assertNotNull($a->getB());
$this->assertNotNull($a->getB()->getC());
diff --git a/tests/simple_unit/SqlMap/common.php b/tests/simple_unit/SqlMap/common.php index 57685c31..aed11671 100644 --- a/tests/simple_unit/SqlMap/common.php +++ b/tests/simple_unit/SqlMap/common.php @@ -41,7 +41,7 @@ class DefaultScriptRunner {
$line = trim($line);
if(strlen($line) > 0)
- $connection->execute($line);
+ $connection->createCommand($line)->execute();
}
}
}
@@ -84,15 +84,16 @@ class SQLiteBaseTestConfig extends BaseTestConfig return new CopyFileScriptRunner($this->baseFile, $this->targetFile);
}
}
-/*
+
class MySQLBaseTestConfig extends BaseTestConfig
{
public function __construct()
{
- $this->_sqlmap = SQLMAP_TESTS.'/mysql.xml';
- $this->_connectionString = 'mysql://root:weizhuo01@localhost/IBatisNet';
+ $this->_sqlmapConfigFile = SQLMAP_TESTS.'/mysql.xml';
$this->_scriptDir = SQLMAP_TESTS.'/scripts/mysql/';
$this->_features = array('insert_id');
+ $dsn = 'mysql:host=localhost;dbname=sqlmap_test';
+ $this->_connection = new TDbConnection($dsn, 'test', 'test111');
}
}
@@ -106,7 +107,6 @@ class MSSQLBaseTestConfig extends BaseTestConfig $this->_features = array('insert_id');
}
}
-*/
class BaseTestConfig
{
@@ -143,9 +143,9 @@ class BaseTestConfig {
//change this to connection to a different database
- //return new MySQLBaseTestConfig();
+ return new MySQLBaseTestConfig();
- return new SQLiteBaseTestConfig();
+ //return new SQLiteBaseTestConfig();
//return new MSSQLBaseTestConfig();
}
diff --git a/tests/simple_unit/SqlMap/maps/MySql/Account.xml b/tests/simple_unit/SqlMap/maps/MySql/Account.xml index 146e0e90..77a1d433 100644 --- a/tests/simple_unit/SqlMap/maps/MySql/Account.xml +++ b/tests/simple_unit/SqlMap/maps/MySql/Account.xml @@ -70,7 +70,7 @@ <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="BannerOptions" column="Account_Banner_Option" typeHandler="OuiNonBool"/>
<result property="CartOptions" column="Account_Cart_Option" typeHandler="HundredsBool"/>
</resultMap>
<resultMap id="indexed-account-result" class="Account">
@@ -551,9 +551,9 @@ <!-- accounts and orders -->
<select id="getAccountWithOrders" resultMap="Account-with-Orders">
- SELECT * FROM accounts
- LEFT JOIN orders ON
- accounts.account_id = orders.account_id
+ SELECT * FROM Accounts
+ LEFT JOIN Orders ON
+ Accounts.account_id = Orders.account_id
</select>
<resultMap id="Account-with-Orders" class="AccountWithOrders" groupBy="Account_Id">
diff --git a/tests/simple_unit/SqlMap/maps/MySql/ActiveRecord.xml b/tests/simple_unit/SqlMap/maps/MySql/ActiveRecord.xml new file mode 100644 index 00000000..1c48010f --- /dev/null +++ b/tests/simple_unit/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/simple_unit/SqlMap/maps/MySql/DynamicAccount.xml b/tests/simple_unit/SqlMap/maps/MySql/DynamicAccount.xml index ff89720b..ee565158 100644 --- a/tests/simple_unit/SqlMap/maps/MySql/DynamicAccount.xml +++ b/tests/simple_unit/SqlMap/maps/MySql/DynamicAccount.xml @@ -49,7 +49,7 @@ </dynamic>
</select>
- <!-- IBATISNET-114: remapResults -->
+ <!-- IBATISNET-114: remapResults
<statement id="DynamicSqlOnColumnSelection"
parameterClass="Account"
resultClass="Account"
@@ -69,6 +69,7 @@ FROM
Accounts
</statement>
+ -->
<statement id="DynamicIsEqual"
parameterClass="string"
diff --git a/tests/simple_unit/SqlMap/maps/MySql/Order.xml b/tests/simple_unit/SqlMap/maps/MySql/Order.xml index 2e4eb616..ac3b7b84 100644 --- a/tests/simple_unit/SqlMap/maps/MySql/Order.xml +++ b/tests/simple_unit/SqlMap/maps/MySql/Order.xml @@ -76,15 +76,15 @@ </resultMap>
<resultMap id="order-with-types-result" class="Order">
- <result property="Id" column="Order_Id" dbType="Int32"/>
- <result property="Date" column="Order_Date" type="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"/>
+ <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">
diff --git a/tests/simple_unit/SqlMap/mysql.xml b/tests/simple_unit/SqlMap/mysql.xml index d6e58b2c..11d6e4bc 100644 --- a/tests/simple_unit/SqlMap/mysql.xml +++ b/tests/simple_unit/SqlMap/mysql.xml @@ -1,21 +1,15 @@ <?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>
-
+ <properties>
+ <property name="selectKey" value="select @@IDENTITY as value" />
+ <property name="MyCategoryName" value="'Film'" />
+ <property name="accountName" value="'Joe'" />
+ </properties>
+
<typeHandlers>
- <typeHandler type="bool" dbType="Varchar" callback="OuiNonBool"/>
+ <typeHandler dbType="Varchar" class="OuiNonBool"/>
+ <typeHandler dbType="date" class="TDateTimeHandler" />
</typeHandlers>
<sqlMaps>
@@ -29,5 +23,7 @@ <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/simple_unit/SqlMap/scripts/mysql/DataBase.sql b/tests/simple_unit/SqlMap/scripts/mysql/DataBase.sql index b6542cdb..2cf1e502 100644 --- a/tests/simple_unit/SqlMap/scripts/mysql/DataBase.sql +++ b/tests/simple_unit/SqlMap/scripts/mysql/DataBase.sql @@ -1,214 +1,356 @@ -use mysql;
-
-drop database IBatisNet;
-create database IBatisNet;
-
-drop database NHibernate;
-create database NHibernate;
-
-grant all privileges on IBatisNet.* to IBatisNet@'%' identified by 'test';
-grant all privileges on IBatisNet.* to IBatisNet@localhost identified by 'test';
-grant all privileges on IBatisNet.* to IBatisNet@localhost.localdomain identified by 'test';
-
-grant all privileges on NHibernate.* to NHibernate@'%' identified by 'test';
-grant all privileges on NHibernate.* to NHibernate@localhost identified by 'test';
-grant all privileges on NHibernate.* to NHibernate@localhost.localdomain identified by 'test';
-
-
-/*==============================================================*/
-/* Nom de la base : MYSQL */
-/* Nom de SGBD : MySQL 3.23 */
-/* Date de cr閍tion : 27/05/2004 20:51:40 */
-/*==============================================================*/
-
-use IBatisNet;
-
-drop table if exists Accounts;
-
-drop table if exists Categories;
-
-drop table if exists Enumerations;
-
-drop table if exists LineItems;
-
-drop table if exists Orders;
-
-drop table if exists Others;
-
-drop table if exists Documents;
-
-/*==============================================================*/
-/* Table : Accounts */
-/*==============================================================*/
-create table Accounts
-(
- Account_Id int not null,
- 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,
- primary key (Account_Id)
-) TYPE=INNODB;
-
-/*==============================================================*/
-/* Table : Categories */
-/*==============================================================*/
-create table Categories
-(
- Category_Id int not null AUTO_INCREMENT,
- Category_Name varchar(32),
- Category_Guid varchar(36),
- primary key (Category_Id)
-) TYPE=INNODB;
-
-/*==============================================================*/
-/* Table : Enumerations */
-/*==============================================================*/
-create table Enumerations
-(
- Enum_Id int not null,
- Enum_Day int not null,
- Enum_Color int not null,
- Enum_Month int,
- primary key (Enum_Id)
-) TYPE=INNODB;
-
-/*==============================================================*/
-/* Table : LineItems */
-/*==============================================================*/
-create table 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),
- LineItem_Picture blob,
- primary key (Order_Id, LineItem_Id)
-) TYPE=INNODB;
-
-/*==============================================================*/
-/* Table : Orders */
-/*==============================================================*/
-create table Orders
-(
- Order_Id int not null,
- Account_Id int null,
- 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,
- primary key (Order_Id)
-) TYPE=INNODB;
-
-/*==============================================================*/
-/* Table : Others */
-/*==============================================================*/
-create table Others
-(
- Other_Int int,
- Other_Long bigint,
- Other_Bit bit not null default 0,
- Other_String varchar(32) not null
-) TYPE=INNODB;
-
-CREATE TABLE F (
- ID varchar(50) NOT NULL ,
- F_Libelle varchar(50) NULL ,
- primary key (ID)
-) TYPE=INNODB;
-
-CREATE TABLE E (
- ID varchar(50) NOT NULL ,
- E_Libelle varchar(50) NULL ,
- primary key (ID)
-) TYPE=INNODB;
-
-CREATE TABLE D (
- ID varchar(50) NOT NULL ,
- D_Libelle varchar(50) NULL ,
- primary key (ID)
-) TYPE=INNODB;
-
-CREATE TABLE C (
- ID varchar(50) NOT NULL ,
- C_Libelle varchar(50) NULL ,
- primary key (ID)
-) TYPE=INNODB;
-
-
-CREATE TABLE B (
- ID varchar(50) NOT NULL ,
- C_ID varchar(50) NULL ,
- D_ID varchar(50) NULL ,
- B_Libelle varchar(50) NULL ,
- primary key (ID)
-) TYPE=INNODB;
-
-ALTER TABLE B ADD CONSTRAINT FK_B_C FOREIGN KEY FK_B_C (C_ID)
- REFERENCES C (ID)
- ON DELETE RESTRICT
- ON UPDATE RESTRICT,
- ADD CONSTRAINT FK_B_D FOREIGN KEY FK_B_D (D_ID)
- REFERENCES D (ID)
- ON DELETE RESTRICT
- ON UPDATE RESTRICT;
-
-CREATE TABLE 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 ,
- primary key (ID)
-) TYPE=INNODB;
-
-ALTER TABLE A ADD CONSTRAINT FK_A_B FOREIGN KEY FK_A_B (B_ID)
- REFERENCES B (ID)
- ON DELETE RESTRICT
- ON UPDATE RESTRICT,
- ADD CONSTRAINT FK_A_E FOREIGN KEY FK_A_E (E_ID)
- REFERENCES E (ID)
- ON DELETE RESTRICT
- ON UPDATE RESTRICT,
- ADD CONSTRAINT FK_A_F FOREIGN KEY FK_A_F (F_ID)
- REFERENCES F (ID)
- ON DELETE RESTRICT;
-
-/*==============================================================*/
-/* Table : Documents */
-/*==============================================================*/
-create table Documents
-(
- Document_Id int not null,
- Document_Title varchar(32),
- Document_Type varchar(32),
- Document_PageNumber int,
- Document_City varchar(32),
- primary key (DOCUMENT_ID)
-) TYPE=INNODB;
-
-
-
-use NHibernate;
-
-drop table if exists Users;
-
-/*==============================================================*/
-/* Table : 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)
-) TYPE=INNODB;
+--
+-- 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/simple_unit/SqlMap/scripts/mysql/account-init.sql b/tests/simple_unit/SqlMap/scripts/mysql/account-init.sql index 51b315f4..afe8dab1 100644 --- a/tests/simple_unit/SqlMap/scripts/mysql/account-init.sql +++ b/tests/simple_unit/SqlMap/scripts/mysql/account-init.sql @@ -1,17 +1,4 @@ -use IBatisNet;
-
-drop table if exists Accounts;
-
-create table Accounts
-(
- Account_Id int not null,
- 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,
- primary key (Account_Id)
-) TYPE=INNODB;
+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);
diff --git a/tests/simple_unit/SqlMap/scripts/mysql/account-procedure.sql b/tests/simple_unit/SqlMap/scripts/mysql/account-procedure.sql index 03b65b13..d3f5a12f 100644 --- a/tests/simple_unit/SqlMap/scripts/mysql/account-procedure.sql +++ b/tests/simple_unit/SqlMap/scripts/mysql/account-procedure.sql @@ -1,2 +1 @@ -use IBatisNet;
\ No newline at end of file diff --git a/tests/simple_unit/SqlMap/scripts/mysql/category-init.sql b/tests/simple_unit/SqlMap/scripts/mysql/category-init.sql index 2f50ff24..2030181d 100644 --- a/tests/simple_unit/SqlMap/scripts/mysql/category-init.sql +++ b/tests/simple_unit/SqlMap/scripts/mysql/category-init.sql @@ -1,12 +1 @@ -
-use IBatisNet;
-
-drop table if exists Categories;
-
-create table Categories
-(
- Category_Id int not null AUTO_INCREMENT,
- Category_Name varchar(32),
- Category_Guid varchar(36),
- primary key (Category_Id)
-) TYPE=INNODB;
+TRUNCATE `Categories`;
diff --git a/tests/simple_unit/SqlMap/scripts/mysql/category-procedure.sql b/tests/simple_unit/SqlMap/scripts/mysql/category-procedure.sql index 03b65b13..e69de29b 100644 --- a/tests/simple_unit/SqlMap/scripts/mysql/category-procedure.sql +++ b/tests/simple_unit/SqlMap/scripts/mysql/category-procedure.sql @@ -1,2 +0,0 @@ -
-use IBatisNet;
\ No newline at end of file diff --git a/tests/simple_unit/SqlMap/scripts/mysql/documents-init.sql b/tests/simple_unit/SqlMap/scripts/mysql/documents-init.sql index c254ae4d..5a1cdb2a 100644 --- a/tests/simple_unit/SqlMap/scripts/mysql/documents-init.sql +++ b/tests/simple_unit/SqlMap/scripts/mysql/documents-init.sql @@ -1,16 +1,4 @@ -use IBatisNet;
-
-drop table if exists Documents;
-
-create table Documents
-(
- Document_Id int not null,
- Document_Title varchar(32),
- Document_Type varchar(32),
- Document_PageNumber int,
- Document_City varchar(32),
- primary key (DOCUMENT_ID)
-) TYPE=INNODB;
+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');
diff --git a/tests/simple_unit/SqlMap/scripts/mysql/enumeration-init.sql b/tests/simple_unit/SqlMap/scripts/mysql/enumeration-init.sql index a194b636..bc296957 100644 --- a/tests/simple_unit/SqlMap/scripts/mysql/enumeration-init.sql +++ b/tests/simple_unit/SqlMap/scripts/mysql/enumeration-init.sql @@ -1,16 +1,4 @@ -
-use IBatisNet;
-
-drop table if exists Enumerations;
-
-create table Enumerations
-(
- Enum_Id int not null,
- Enum_Day int not null,
- Enum_Color int not null,
- Enum_Month int,
- primary key (Enum_Id)
-) TYPE=INNODB;
+TRUNCATE `Enumerations`;
INSERT INTO Enumerations VALUES(1, 1, 1, 128);
INSERT INTO Enumerations VALUES(2, 2, 2, 2048);
diff --git a/tests/simple_unit/SqlMap/scripts/mysql/line-item-init.sql b/tests/simple_unit/SqlMap/scripts/mysql/line-item-init.sql index cb800835..b0f7e424 100644 --- a/tests/simple_unit/SqlMap/scripts/mysql/line-item-init.sql +++ b/tests/simple_unit/SqlMap/scripts/mysql/line-item-init.sql @@ -1,18 +1,5 @@ -use IBatisNet;
-
-drop table if exists LineItems;
-
-create table 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),
- LineItem_Picture blob,
- primary key (Order_Id, LineItem_Id)
-) TYPE=INNODB;
+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);
diff --git a/tests/simple_unit/SqlMap/scripts/mysql/order-init.sql b/tests/simple_unit/SqlMap/scripts/mysql/order-init.sql index e83a4be3..5c23081f 100644 --- a/tests/simple_unit/SqlMap/scripts/mysql/order-init.sql +++ b/tests/simple_unit/SqlMap/scripts/mysql/order-init.sql @@ -1,20 +1,5 @@ -drop table if exists Orders;
+TRUNCATE `Orders`;
-create table Orders
-(
- Order_Id int not null,
- Account_Id int null,
- 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,
- primary key (Order_Id)
-) TYPE=INNODB;
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);
diff --git a/tests/simple_unit/SqlMap/scripts/mysql/other-init.sql b/tests/simple_unit/SqlMap/scripts/mysql/other-init.sql index 0281527c..e3ed6b32 100644 --- a/tests/simple_unit/SqlMap/scripts/mysql/other-init.sql +++ b/tests/simple_unit/SqlMap/scripts/mysql/other-init.sql @@ -1,84 +1,11 @@ -use IBatisNet;
-
-drop table if exists Others;
-drop table if exists A;
-drop table if exists B;
-drop table if exists C;
-drop table if exists D;
-drop table if exists E;
-drop table if exists F;
-
-create table Others
-(
- Other_Int int,
- Other_Long bigint,
- Other_Bit bit not null default 0,
- Other_String varchar(32) not null
-) TYPE=INNODB;
-
-CREATE TABLE F (
- ID varchar(50) NOT NULL ,
- F_Libelle varchar(50) NULL ,
- primary key (ID)
-) TYPE=INNODB;
-
-CREATE TABLE E (
- ID varchar(50) NOT NULL ,
- E_Libelle varchar(50) NULL ,
- primary key (ID)
-) TYPE=INNODB;
-
-CREATE TABLE D (
- ID varchar(50) NOT NULL ,
- D_Libelle varchar(50) NULL ,
- primary key (ID)
-) TYPE=INNODB;
-
-CREATE TABLE C (
- ID varchar(50) NOT NULL ,
- C_Libelle varchar(50) NULL ,
- primary key (ID)
-) TYPE=INNODB;
-
-
-CREATE TABLE B (
- ID varchar(50) NOT NULL ,
- C_ID varchar(50) NULL ,
- D_ID varchar(50) NULL ,
- B_Libelle varchar(50) NULL ,
- primary key (ID)
-) TYPE=INNODB;
-
-ALTER TABLE B ADD CONSTRAINT FK_B_C FOREIGN KEY FK_B_C (C_ID)
- REFERENCES C (ID)
- ON DELETE RESTRICT
- ON UPDATE RESTRICT,
- ADD CONSTRAINT FK_B_D FOREIGN KEY FK_B_D (D_ID)
- REFERENCES D (ID)
- ON DELETE RESTRICT
- ON UPDATE RESTRICT;
-
-CREATE TABLE 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 ,
- primary key (ID)
-) TYPE=INNODB;
-
-ALTER TABLE A ADD CONSTRAINT FK_A_B FOREIGN KEY FK_A_B (B_ID)
- REFERENCES B (ID)
- ON DELETE RESTRICT
- ON UPDATE RESTRICT,
- ADD CONSTRAINT FK_A_E FOREIGN KEY FK_A_E (E_ID)
- REFERENCES E (ID)
- ON DELETE RESTRICT
- ON UPDATE RESTRICT,
- ADD CONSTRAINT FK_A_F FOREIGN KEY FK_A_F (F_ID)
- REFERENCES F (ID)
- ON DELETE RESTRICT;
+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');
diff --git a/tests/simple_unit/SqlMap/scripts/mysql/swap-procedure.sql b/tests/simple_unit/SqlMap/scripts/mysql/swap-procedure.sql index 03b65b13..e69de29b 100644 --- a/tests/simple_unit/SqlMap/scripts/mysql/swap-procedure.sql +++ b/tests/simple_unit/SqlMap/scripts/mysql/swap-procedure.sql @@ -1,2 +0,0 @@ -
-use IBatisNet;
\ No newline at end of file diff --git a/tests/simple_unit/SqlMap/scripts/mysql/user-init.sql b/tests/simple_unit/SqlMap/scripts/mysql/user-init.sql index c124fc2b..0bcd6a65 100644 --- a/tests/simple_unit/SqlMap/scripts/mysql/user-init.sql +++ b/tests/simple_unit/SqlMap/scripts/mysql/user-init.sql @@ -1,14 +1,2 @@ -use NHibernate;
-
-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)
-) TYPE=INNODB;
+TRUNCATE `users`;
|