Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 7ad3e01

Browse files
committed
CreateTable fails in Postgres after either DialectProvider.UseUnicode or DialectProvider.DefaultStringLength is changed.
1 parent 9300fd0 commit 7ad3e01

File tree

2 files changed

+161
-112
lines changed

2 files changed

+161
-112
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.ComponentModel.DataAnnotations;
4+
using System.Linq;
5+
using System.Text;
6+
using NUnit.Framework;
7+
using ServiceStack.DataAnnotations;
8+
using ServiceStack.OrmLite.Tests;
9+
10+
namespace ServiceStack.OrmLite.PostgreSQL.Tests
11+
{
12+
[TestFixture]
13+
public class CreatePostgreSQLTablesTests : OrmLiteTestBase
14+
{
15+
16+
[Test]
17+
public void can_create_tables_after_UseUnicode_or_DefaultStringLenght_changed()
18+
{
19+
//first one passes
20+
_reCreateTheTable();
21+
22+
//table creation fails after either of these:
23+
//OrmLiteConfig.DialectProvider.UseUnicode = true;
24+
//OrmLiteConfig.DialectProvider.UseUnicode = false;
25+
OrmLiteConfig.DialectProvider.DefaultStringLength = 123;
26+
27+
_reCreateTheTable();
28+
}
29+
30+
private void _reCreateTheTable()
31+
{
32+
using(var db = ConnectionString.OpenDbConnection()) {
33+
db.CreateTable<CreatePostgreSQLTablesTests_dummy_table>(true);
34+
}
35+
}
36+
37+
private class CreatePostgreSQLTablesTests_dummy_table
38+
{
39+
[AutoIncrement]
40+
public int Id { get; set; }
41+
42+
public String StringNoExplicitLength { get; set; }
43+
44+
[StringLength(100)]
45+
public String String100Characters { get; set; }
46+
}
47+
}
48+
}
Lines changed: 113 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -1,119 +1,120 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<PropertyGroup>
4-
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5-
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6-
<ProductVersion>8.0.30703</ProductVersion>
7-
<SchemaVersion>2.0</SchemaVersion>
8-
<ProjectGuid>{E692B423-82E9-46DE-AA80-F4E36A4B4D56}</ProjectGuid>
9-
<OutputType>Library</OutputType>
10-
<AppDesignerFolder>Properties</AppDesignerFolder>
11-
<RootNamespace>ServiceStack.OrmLite.PostgreSQL.Tests</RootNamespace>
12-
<AssemblyName>ServiceStack.OrmLite.PostgreSQL.Tests</AssemblyName>
13-
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
14-
<FileAlignment>512</FileAlignment>
15-
</PropertyGroup>
16-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17-
<DebugSymbols>true</DebugSymbols>
18-
<DebugType>full</DebugType>
19-
<Optimize>false</Optimize>
20-
<OutputPath>bin\Debug\</OutputPath>
21-
<DefineConstants>DEBUG;TRACE</DefineConstants>
22-
<ErrorReport>prompt</ErrorReport>
23-
<WarningLevel>4</WarningLevel>
24-
</PropertyGroup>
25-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26-
<DebugType>pdbonly</DebugType>
27-
<Optimize>true</Optimize>
28-
<OutputPath>bin\Release\</OutputPath>
29-
<DefineConstants>TRACE</DefineConstants>
30-
<ErrorReport>prompt</ErrorReport>
31-
<WarningLevel>4</WarningLevel>
32-
</PropertyGroup>
33-
<ItemGroup>
34-
<Reference Include="Northwind.Perf">
35-
<HintPath>..\..\lib\tests\Northwind.Perf.dll</HintPath>
36-
</Reference>
37-
<Reference Include="Npgsql">
38-
<HintPath>..\..\lib\Npgsql.dll</HintPath>
39-
</Reference>
40-
<Reference Include="ServiceStack.Common">
41-
<HintPath>..\..\lib\ServiceStack.Common.dll</HintPath>
42-
</Reference>
43-
<Reference Include="ServiceStack.Common.Tests">
44-
<HintPath>..\..\lib\tests\ServiceStack.Common.Tests.dll</HintPath>
45-
</Reference>
46-
<Reference Include="ServiceStack.Interfaces">
47-
<HintPath>..\..\lib\ServiceStack.Interfaces.dll</HintPath>
48-
</Reference>
49-
<Reference Include="System" />
50-
<Reference Include="System.ComponentModel.DataAnnotations" />
51-
<Reference Include="System.Core" />
52-
<Reference Include="System.Xml.Linq" />
53-
<Reference Include="System.Data.DataSetExtensions" />
54-
<Reference Include="System.Data" />
55-
<Reference Include="System.Xml" />
56-
<Reference Include="Northwind.Common">
57-
<HintPath>..\..\lib\tests\Northwind.Common.dll</HintPath>
58-
</Reference>
59-
<Reference Include="nunit.framework">
60-
<HintPath>..\..\lib\tests\nunit.framework.dll</HintPath>
61-
</Reference>
62-
<Reference Include="ServiceStack.Text">
63-
<HintPath>..\..\lib\ServiceStack.Text.dll</HintPath>
64-
</Reference>
65-
<Reference Include="System.Configuration" />
66-
</ItemGroup>
67-
<ItemGroup>
68-
<Compile Include="EnumTests.cs" />
69-
<Compile Include="Expressions\AdditiveExpressionsTest.cs" />
70-
<Compile Include="Expressions\Author.cs" />
71-
<Compile Include="Expressions\AuthorUseCase.cs" />
72-
<Compile Include="Expressions\ConditionalExpressionTest.cs" />
73-
<Compile Include="Expressions\EqualityExpressionsTest.cs" />
74-
<Compile Include="Expressions\ExpressionsTestBase.cs" />
75-
<Compile Include="Expressions\LogicalExpressionsTest.cs" />
76-
<Compile Include="Expressions\MultiplicativeExpressionsTest.cs" />
77-
<Compile Include="Expressions\OrmLiteCountTests.cs" />
78-
<Compile Include="Expressions\PrimaryExpressionsTest.cs" />
79-
<Compile Include="Expressions\RelationalExpressionsTest.cs" />
80-
<Compile Include="Expressions\StringFunctionTests.cs" />
81-
<Compile Include="Expressions\TestType.cs" />
82-
<Compile Include="Expressions\UnaryExpressionsTest.cs" />
83-
<Compile Include="ForeignKeyAttributeTests.cs" />
84-
<Compile Include="NorthwindPerfTests.cs" />
85-
<Compile Include="OrmLiteBasicPersistenceProviderTests.cs" />
86-
<Compile Include="OrmLiteCreateTableWithNamigStrategyTests.cs" />
87-
<Compile Include="OrmLiteInsertTests.cs" />
88-
<Compile Include="OrmLiteNorthwindTests.cs" />
89-
<Compile Include="OrmLiteSelectTests.cs" />
90-
<Compile Include="OrmLiteTestBase.cs" />
91-
<Compile Include="Properties\AssemblyInfo.cs" />
92-
<Compile Include="OrmLiteGetScalarTests.cs" />
93-
<Compile Include="SchemaTests.cs" />
94-
<Compile Include="TypeWithByteArrayFieldTests.cs" />
95-
</ItemGroup>
96-
<ItemGroup>
97-
<None Include="app.config">
98-
<SubType>Designer</SubType>
99-
</None>
100-
</ItemGroup>
101-
<ItemGroup>
102-
<ProjectReference Include="..\ServiceStack.OrmLite.PostgreSQL\ServiceStack.OrmLite.PostgreSQL.csproj">
103-
<Project>{3220F088-BDD0-6979-AC0C-8C541C2E7DE5}</Project>
104-
<Name>ServiceStack.OrmLite.PostgreSQL</Name>
105-
</ProjectReference>
106-
<ProjectReference Include="..\ServiceStack.OrmLite\ServiceStack.OrmLite.csproj">
107-
<Project>{96179AC6-F6F1-40C3-9FDD-4F6582F54C5C}</Project>
108-
<Name>ServiceStack.OrmLite</Name>
109-
</ProjectReference>
110-
</ItemGroup>
111-
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProductVersion>8.0.30703</ProductVersion>
7+
<SchemaVersion>2.0</SchemaVersion>
8+
<ProjectGuid>{E692B423-82E9-46DE-AA80-F4E36A4B4D56}</ProjectGuid>
9+
<OutputType>Library</OutputType>
10+
<AppDesignerFolder>Properties</AppDesignerFolder>
11+
<RootNamespace>ServiceStack.OrmLite.PostgreSQL.Tests</RootNamespace>
12+
<AssemblyName>ServiceStack.OrmLite.PostgreSQL.Tests</AssemblyName>
13+
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
14+
<FileAlignment>512</FileAlignment>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<DebugSymbols>true</DebugSymbols>
18+
<DebugType>full</DebugType>
19+
<Optimize>false</Optimize>
20+
<OutputPath>bin\Debug\</OutputPath>
21+
<DefineConstants>DEBUG;TRACE</DefineConstants>
22+
<ErrorReport>prompt</ErrorReport>
23+
<WarningLevel>4</WarningLevel>
24+
</PropertyGroup>
25+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26+
<DebugType>pdbonly</DebugType>
27+
<Optimize>true</Optimize>
28+
<OutputPath>bin\Release\</OutputPath>
29+
<DefineConstants>TRACE</DefineConstants>
30+
<ErrorReport>prompt</ErrorReport>
31+
<WarningLevel>4</WarningLevel>
32+
</PropertyGroup>
33+
<ItemGroup>
34+
<Reference Include="Northwind.Perf">
35+
<HintPath>..\..\lib\tests\Northwind.Perf.dll</HintPath>
36+
</Reference>
37+
<Reference Include="Npgsql">
38+
<HintPath>..\..\lib\Npgsql.dll</HintPath>
39+
</Reference>
40+
<Reference Include="ServiceStack.Common">
41+
<HintPath>..\..\lib\ServiceStack.Common.dll</HintPath>
42+
</Reference>
43+
<Reference Include="ServiceStack.Common.Tests">
44+
<HintPath>..\..\lib\tests\ServiceStack.Common.Tests.dll</HintPath>
45+
</Reference>
46+
<Reference Include="ServiceStack.Interfaces">
47+
<HintPath>..\..\lib\ServiceStack.Interfaces.dll</HintPath>
48+
</Reference>
49+
<Reference Include="System" />
50+
<Reference Include="System.ComponentModel.DataAnnotations" />
51+
<Reference Include="System.Core" />
52+
<Reference Include="System.Xml.Linq" />
53+
<Reference Include="System.Data.DataSetExtensions" />
54+
<Reference Include="System.Data" />
55+
<Reference Include="System.Xml" />
56+
<Reference Include="Northwind.Common">
57+
<HintPath>..\..\lib\tests\Northwind.Common.dll</HintPath>
58+
</Reference>
59+
<Reference Include="nunit.framework">
60+
<HintPath>..\..\lib\tests\nunit.framework.dll</HintPath>
61+
</Reference>
62+
<Reference Include="ServiceStack.Text">
63+
<HintPath>..\..\lib\ServiceStack.Text.dll</HintPath>
64+
</Reference>
65+
<Reference Include="System.Configuration" />
66+
</ItemGroup>
67+
<ItemGroup>
68+
<Compile Include="CreatePostgreSQLTablesTests.cs" />
69+
<Compile Include="EnumTests.cs" />
70+
<Compile Include="Expressions\AdditiveExpressionsTest.cs" />
71+
<Compile Include="Expressions\Author.cs" />
72+
<Compile Include="Expressions\AuthorUseCase.cs" />
73+
<Compile Include="Expressions\ConditionalExpressionTest.cs" />
74+
<Compile Include="Expressions\EqualityExpressionsTest.cs" />
75+
<Compile Include="Expressions\ExpressionsTestBase.cs" />
76+
<Compile Include="Expressions\LogicalExpressionsTest.cs" />
77+
<Compile Include="Expressions\MultiplicativeExpressionsTest.cs" />
78+
<Compile Include="Expressions\OrmLiteCountTests.cs" />
79+
<Compile Include="Expressions\PrimaryExpressionsTest.cs" />
80+
<Compile Include="Expressions\RelationalExpressionsTest.cs" />
81+
<Compile Include="Expressions\StringFunctionTests.cs" />
82+
<Compile Include="Expressions\TestType.cs" />
83+
<Compile Include="Expressions\UnaryExpressionsTest.cs" />
84+
<Compile Include="ForeignKeyAttributeTests.cs" />
85+
<Compile Include="NorthwindPerfTests.cs" />
86+
<Compile Include="OrmLiteBasicPersistenceProviderTests.cs" />
87+
<Compile Include="OrmLiteCreateTableWithNamigStrategyTests.cs" />
88+
<Compile Include="OrmLiteInsertTests.cs" />
89+
<Compile Include="OrmLiteNorthwindTests.cs" />
90+
<Compile Include="OrmLiteSelectTests.cs" />
91+
<Compile Include="OrmLiteTestBase.cs" />
92+
<Compile Include="Properties\AssemblyInfo.cs" />
93+
<Compile Include="OrmLiteGetScalarTests.cs" />
94+
<Compile Include="SchemaTests.cs" />
95+
<Compile Include="TypeWithByteArrayFieldTests.cs" />
96+
</ItemGroup>
97+
<ItemGroup>
98+
<None Include="app.config">
99+
<SubType>Designer</SubType>
100+
</None>
101+
</ItemGroup>
102+
<ItemGroup>
103+
<ProjectReference Include="..\ServiceStack.OrmLite.PostgreSQL\ServiceStack.OrmLite.PostgreSQL.csproj">
104+
<Project>{3220F088-BDD0-6979-AC0C-8C541C2E7DE5}</Project>
105+
<Name>ServiceStack.OrmLite.PostgreSQL</Name>
106+
</ProjectReference>
107+
<ProjectReference Include="..\ServiceStack.OrmLite\ServiceStack.OrmLite.csproj">
108+
<Project>{96179AC6-F6F1-40C3-9FDD-4F6582F54C5C}</Project>
109+
<Name>ServiceStack.OrmLite</Name>
110+
</ProjectReference>
111+
</ItemGroup>
112+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
112113
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
113114
Other similar extension points exist, see Microsoft.Common.targets.
114115
<Target Name="BeforeBuild">
115116
</Target>
116117
<Target Name="AfterBuild">
117118
</Target>
118-
-->
119+
-->
119120
</Project>

0 commit comments

Comments
 (0)