2
2
using NHibernate . Engine ;
3
3
using NHibernate . SqlCommand ;
4
4
using NHibernate . SqlTypes ;
5
- using NHibernate . Type ;
6
5
using NUnit . Framework ;
7
6
8
7
namespace NHibernate . Test . SqlCommandTest
@@ -26,15 +25,13 @@ public void InsertSqlStringTest()
26
25
27
26
insert . AddColumn ( "intColumn" , NHibernateUtil . Int32 ) ;
28
27
insert . AddColumn ( "longColumn" , NHibernateUtil . Int64 ) ;
29
- insert . AddColumn ( "literalColumn" , false , ( ILiteralType ) NHibernateUtil . Boolean ) ;
30
28
insert . AddColumn ( "stringColumn" , 5 . ToString ( ) ) ;
31
29
32
30
SqlCommandInfo sqlCommand = insert . ToSqlCommandInfo ( ) ;
33
31
SqlType [ ] actualParameterTypes = sqlCommand . ParameterTypes ;
34
32
35
- string falseString = factoryImpl . Dialect . ToBooleanValueString ( false ) ;
36
33
string expectedSql =
37
- "INSERT INTO test_insert_builder (intColumn, longColumn, literalColumn, stringColumn) VALUES (?, ?, " + falseString + " , 5)";
34
+ "INSERT INTO test_insert_builder (intColumn, longColumn, stringColumn) VALUES (?, ?, 5)" ;
38
35
Assert . AreEqual ( expectedSql , sqlCommand . Text . ToString ( ) , "SQL String" ) ;
39
36
40
37
Assert . AreEqual ( 2 , actualParameterTypes . Length ) ;
@@ -48,15 +45,15 @@ public void Commented()
48
45
Configuration cfg = new Configuration ( ) ;
49
46
ISessionFactory factory = cfg . BuildSessionFactory ( ) ;
50
47
51
- ISessionFactoryImplementor factoryImpl = ( ISessionFactoryImplementor ) factory ;
48
+ ISessionFactoryImplementor factoryImpl = ( ISessionFactoryImplementor ) factory ;
52
49
SqlInsertBuilder insert = new SqlInsertBuilder ( factoryImpl ) ;
53
50
54
51
insert . SetTableName ( "test_insert_builder" ) ;
55
52
56
- insert . AddColumn ( "stringColumn " , "aSQLValue" , ( ILiteralType ) NHibernateUtil . String ) ;
53
+ insert . AddColumn ( "intColumn " , NHibernateUtil . Int32 ) ;
57
54
insert . SetComment ( "Test insert" ) ;
58
55
string expectedSql =
59
- "/* Test insert */ INSERT INTO test_insert_builder (stringColumn ) VALUES ('aSQLValue' )" ;
56
+ "/* Test insert */ INSERT INTO test_insert_builder (intColumn ) VALUES (? )" ;
60
57
Assert . AreEqual ( expectedSql , insert . ToSqlString ( ) . ToString ( ) , "SQL String" ) ;
61
58
}
62
59
@@ -66,27 +63,25 @@ public void MixingParametersAndValues()
66
63
Configuration cfg = new Configuration ( ) ;
67
64
ISessionFactory factory = cfg . BuildSessionFactory ( ) ;
68
65
69
- ISessionFactoryImplementor factoryImpl = ( ISessionFactoryImplementor ) factory ;
66
+ ISessionFactoryImplementor factoryImpl = ( ISessionFactoryImplementor ) factory ;
70
67
SqlInsertBuilder insert = new SqlInsertBuilder ( factoryImpl ) ;
71
68
72
69
insert . SetTableName ( "test_insert_builder" ) ;
73
70
74
- insert . AddColumn ( "literalColumn" , false , ( ILiteralType ) NHibernateUtil . Boolean ) ;
75
71
insert . AddColumn ( "intColumn" , NHibernateUtil . Int32 ) ;
76
72
insert . AddColumn ( "stringColumn" , 5 . ToString ( ) ) ;
77
73
insert . AddColumn ( "longColumn" , NHibernateUtil . Int64 ) ;
78
74
79
75
SqlCommandInfo sqlCommand = insert . ToSqlCommandInfo ( ) ;
80
76
SqlType [ ] actualParameterTypes = sqlCommand . ParameterTypes ;
81
77
82
- string falseString = factoryImpl . Dialect . ToBooleanValueString ( false ) ;
83
- string expectedSql =
84
- "INSERT INTO test_insert_builder (literalColumn, intColumn, stringColumn, longColumn) VALUES (" + falseString + ", ?, 5, ?)" ;
78
+ string expectedSql =
79
+ "INSERT INTO test_insert_builder (intColumn, stringColumn, longColumn) VALUES (?, 5, ?)" ;
85
80
Assert . AreEqual ( expectedSql , sqlCommand . Text . ToString ( ) , "SQL String" ) ;
86
81
87
82
Assert . AreEqual ( 2 , actualParameterTypes . Length ) ;
88
83
Assert . AreEqual ( SqlTypeFactory . Int32 , actualParameterTypes [ 0 ] , "First Parameter Type" ) ;
89
- Assert . AreEqual ( SqlTypeFactory . Int64 , actualParameterTypes [ 1 ] , "Second Parameter Type" ) ;
84
+ Assert . AreEqual ( SqlTypeFactory . Int64 , actualParameterTypes [ 1 ] , "Second Parameter Type" ) ;
90
85
}
91
86
}
92
- }
87
+ }
0 commit comments