Skip to content

Commit 018cf1c

Browse files
Merge pull request #1854 from pettersoft/master
Add SQL Anywhere 17 support
2 parents 8061e2b + 06da1c9 commit 018cf1c

File tree

70 files changed

+847
-114
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+847
-114
lines changed

ShowBuildMenu.bat

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,14 @@ echo F. Add a test configuration for Oracle with managed driver.
5757
echo G. Add a test configuration for SQL Server Compact.
5858
echo H. Add a test configuration for MySql.
5959
echo I. Add a test configuration for SAP HANA.
60+
echo J. Add a test configuration for SAP SQL Anywhere.
6061
echo.
6162
echo X. Exit to main menu.
6263
echo.
6364

64-
%BUILDTOOL% prompt ABCDEFGHIX
65-
if errorlevel 9 goto main-menu
65+
%BUILDTOOL% prompt ABCDEFGHIJX
66+
if errorlevel 10 goto main-menu
67+
if errorlevel 9 goto test-setup-anywhere
6668
if errorlevel 8 goto test-setup-hana
6769
if errorlevel 7 goto test-setup-mysql
6870
if errorlevel 6 goto test-setup-sqlserverce
@@ -136,6 +138,13 @@ set LIB_FILES=
136138
set LIB_FILES2=
137139
goto test-setup-generic
138140

141+
:test-setup-anywhere
142+
set CONFIG_NAME=SapSQLAnywhere
143+
set TEST_PLATFORM=AnyCPU
144+
set LIB_FILES=
145+
set LIB_FILES2=
146+
goto test-setup-generic
147+
139148
:test-setup-generic
140149
set CFGNAME=
141150
set /p CFGNAME=Enter a name for your test configuration or press enter to use default name:
@@ -221,12 +230,14 @@ echo I. NHibernate Trunk - Oracle Managed (64-bit)
221230
echo J. NHibernate Trunk - SQL Server Compact (32-bit)
222231
echo K. NHibernate Trunk - SQL Server Compact (64-bit)
223232
echo L. NHibernate Trunk - SQL Server ODBC (32-bit)
233+
echo M. NHibernate Trunk - SAP SQL Anywhere
224234
echo.
225235
echo X. Exit to main menu.
226236
echo.
227237

228-
%BUILDTOOL% prompt ABCDEFGHIJKLX
229-
if errorlevel 12 goto main-menu
238+
%BUILDTOOL% prompt ABCDEFGHIJKLMX
239+
if errorlevel 13 goto main-menu
240+
if errorlevel 12 goto teamcity-anywhere
230241
if errorlevel 11 goto teamcity-sqlServerOdbc
231242
if errorlevel 10 goto teamcity-sqlServerCe64
232243
if errorlevel 9 goto teamcity-sqlServerCe32
@@ -312,5 +323,11 @@ move "%CURRENT_CONFIGURATION%" "%CURRENT_CONFIGURATION%-backup" 2> nul
312323
move "%CURRENT_CONFIGURATION%-backup" "%CURRENT_CONFIGURATION%" 2> nul
313324
goto main-menu
314325

326+
:teamcity-anywhere
327+
move "%CURRENT_CONFIGURATION%" "%CURRENT_CONFIGURATION%-backup" 2> nul
328+
%NANT% /f:teamcity.build -D:skip.manual=true -D:CCNetLabel=-1 -D:config.teamcity=sqlanywhere
329+
move "%CURRENT_CONFIGURATION%-backup" "%CURRENT_CONFIGURATION%" 2> nul
330+
goto main-menu
331+
315332
:end
316333
popd
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Installation steps for SAP SQL Anywhere 17 for NH TeamCity:
2+
1. Download SAP SQL Anywhere 17 from https://www.sap.com/products/sql-anywhere.html.
3+
Please make sure you comply with it's license.
4+
5+
2. Run the installer
6+
3. Ensure the MSDTC Windows service is enabled. All transaction scope tests, even
7+
those normally not distributed, use it with SAP SQL Anywhere 17
8+
9+
The NHibernate.TestDatabaseSetup should normally do on its own the following operations:
10+
1. Create the test database with default options
11+
2. Run the query
12+
set option ansi_update_constraints = 'Off'
13+
(Otherwise some tests will fail.)
14+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
This template was written to work with NHibernate.Test.
4+
Copy the template to your NHibernate.Test project folder and rename it hibernate.cfg.xml. Change it
5+
for your own use before compiling tests in Visual Studio.
6+
-->
7+
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
8+
<session-factory name="NHibernate.Test">
9+
<property name="connection.driver_class">NHibernate.Driver.SapSQLAnywhere17Driver</property>
10+
<!-- Sap.Data.SQLAnywhere does not support re-enlisting in the same transaction, wrecking many usages
11+
with NHibernate when both NHibernate and the connection performs auto-enlistment. Setting
12+
"Enlist=false;" in the connection string solves this.
13+
It also requires to have the MSDTC service running, even for transaction scopes using a
14+
single connection. -->
15+
<property name="connection.connection_string">
16+
UID=DBA;PWD=sql;Server=localhost;DBN=nhibernate;DBF=c:\nhibernate.db;ASTOP=No;Enlist=false;
17+
</property>
18+
<property name="dialect">NHibernate.Dialect.SybaseSQLAnywhere12Dialect</property>
19+
<property name="query.substitutions">true=1;false=0</property>
20+
</session-factory>
21+
</hibernate-configuration>

src/NHibernate.DomainModel/ABCProxy.hbm.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
</id>
1111
<discriminator column="clazz_discriminata" type="Int32" force="true" not-null="false" />
1212
<property name="Name" />
13-
<many-to-one name="Forward" class="E" cascade="save-update" />
14-
13+
<many-to-one name="Forward" column="`Forward`" class="E" cascade="save-update" />
14+
1515
<subclass name="B" lazy="true" discriminator-value="null">
1616
<property name="Count" column="count_" type="Int32" />
1717
<map name="Map">
@@ -56,4 +56,4 @@
5656
<one-to-one name="Reverse" class="A" property-ref="Forward" cascade="save-update" />
5757
</class>
5858

59-
</hibernate-mapping>
59+
</hibernate-mapping>

src/NHibernate.DomainModel/Northwind/Mappings/Shipper.hbm.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<property name="PhoneNumber" column="Phone" type="string" length="24"
1515
access="field.camelcase-underscore"/>
1616

17-
<property name="Reference" column="Reference" type="guid" access="field.camelcase-underscore"/>
17+
<property name="Reference" column="`Reference`" type="guid" access="field.camelcase-underscore"/>
1818

1919
<bag name="Orders" lazy="true" access="field.camelcase-underscore"
2020
cascade="none">
@@ -24,4 +24,4 @@
2424

2525
</class>
2626

27-
</hibernate-mapping>
27+
</hibernate-mapping>

src/NHibernate.Test/Ado/GenericBatchingBatcherFixture.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ protected override bool AppliesTo(Dialect.Dialect dialect)
2929
return !(dialect is FirebirdDialect) &&
3030
!(dialect is Oracle8iDialect) &&
3131
!(dialect is MsSqlCeDialect) &&
32-
!(dialect is HanaDialectBase);
32+
!(dialect is HanaDialectBase) &&
33+
// A workaround exists for SQL Anywhere, see https://stackoverflow.com/a/32860293/1178314
34+
// It would imply some tweaking in the generic batcher. The same workaround could
35+
// be used for enabling future support.
36+
!(dialect is SybaseSQLAnywhere10Dialect);
3337
}
3438

3539
[Test]

src/NHibernate.Test/Async/Ado/GenericBatchingBatcherFixture.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ protected override bool AppliesTo(Dialect.Dialect dialect)
4242
return !(dialect is FirebirdDialect) &&
4343
!(dialect is Oracle8iDialect) &&
4444
!(dialect is MsSqlCeDialect) &&
45-
!(dialect is HanaDialectBase);
45+
!(dialect is HanaDialectBase) &&
46+
// A workaround exists for SQL Anywhere, see https://stackoverflow.com/a/32860293/1178314
47+
// It would imply some tweaking in the generic batcher. The same workaround could
48+
// be used for enabling future support.
49+
!(dialect is SybaseSQLAnywhere10Dialect);
4650
}
4751

4852
[Test]

src/NHibernate.Test/Async/Component/Basic/ComponentWithUniqueConstraintTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ protected override HbmMapping GetMappings()
3232

3333
mapper.Component<Person>(comp =>
3434
{
35-
comp.Property(p => p.Name);
36-
comp.Property(p => p.Dob);
35+
comp.Property(p => p.Name, m => m.NotNullable(true));
36+
comp.Property(p => p.Dob, m => m.NotNullable(true));
3737
comp.Unique(true); // hbm2ddl: Generate a unique constraint in the database
3838
});
3939

@@ -94,9 +94,9 @@ public void CannotBePersistedWithNonUniqueValuesAsync()
9494
await (session.SaveAsync(e2));
9595
await (session.FlushAsync());
9696
});
97-
Assert.That(exception.InnerException, Is.AssignableTo<DbException>());
97+
Assert.That(exception.InnerException, Is.InstanceOf<DbException>());
9898
Assert.That(exception.InnerException.Message,
99-
Does.Contain("unique").IgnoreCase.And.Contains("constraint").IgnoreCase
99+
Does.Contain("unique").IgnoreCase
100100
.Or.Contains("duplicate entry").IgnoreCase);
101101
}
102102
}

src/NHibernate.Test/Async/Criteria/CriteriaQueryTest.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2719,6 +2719,9 @@ public async Task OrderProjectionTestAsync()
27192719
[Test]
27202720
public async Task OrderProjectionAliasedTestAsync()
27212721
{
2722+
if (TestDialect.HasBrokenTypeInferenceOnSelectedParameters)
2723+
Assert.Ignore("Current dialect does not support this test");
2724+
27222725
using (ISession session = OpenSession())
27232726
using (ITransaction t = session.BeginTransaction())
27242727
{

src/NHibernate.Test/Async/Criteria/EntityProjectionsTest.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
//------------------------------------------------------------------------------
99

1010

11+
using NHibernate.Cfg;
1112
using NHibernate.Cfg.MappingSchema;
1213
using NHibernate.Criterion;
1314
using NHibernate.Dialect;
@@ -29,6 +30,11 @@ public class EntityProjectionsTestAsync : TestCaseMappingByCode
2930
private EntityWithCompositeId _entityWithCompositeId;
3031
private EntityCustomEntityName _entityWithCustomEntityName;
3132

33+
protected override void Configure(Configuration configuration)
34+
{
35+
configuration.SetProperty(Environment.FormatSql, "false");
36+
}
37+
3238
protected override HbmMapping GetMappings()
3339
{
3440
var mapper = new ModelMapper();
@@ -252,12 +258,14 @@ public async Task EntityProjectionAsSelectExpressionForArgumentAliasAsync()
252258
[Test]
253259
public async Task EntityProjectionLockModeAsync()
254260
{
261+
// For this test to succeed with SQL Anywhere, ansi_update_constraints must be off.
262+
// In I-SQL: set option ansi_update_constraints = 'Off'
255263
if (Dialect is Oracle8iDialect)
256264
Assert.Ignore("Oracle is not supported due to #1352 bug (NH-3902)");
257265

258266
var upgradeHint = Dialect.ForUpdateString;
259267
if(string.IsNullOrEmpty(upgradeHint))
260-
upgradeHint = this.Dialect.AppendLockHint(LockMode.Upgrade, string.Empty);
268+
upgradeHint = Dialect.AppendLockHint(LockMode.Upgrade, string.Empty);
261269
if (string.IsNullOrEmpty(upgradeHint))
262270
{
263271
Assert.Ignore($"Upgrade hint is not supported by dialect {Dialect.GetType().Name}");

0 commit comments

Comments
 (0)