|
1 | | -// Copyright (C) 2010 Xtensive LLC. |
2 | | -// All rights reserved. |
3 | | -// For conditions of distribution and use, see license. |
| 1 | +// Copyright (C) 2010-2023 Xtensive LLC. |
| 2 | +// This code is distributed under MIT license terms. |
| 3 | +// See the License.txt file in the project root for more information. |
4 | 4 | // Created by: Alexey Gamzov |
5 | 5 | // Created: 2010.01.23 |
6 | 6 |
|
7 | | -using System; |
8 | | -using System.Diagnostics; |
9 | 7 | using System.Text; |
10 | 8 | using NUnit.Framework; |
11 | 9 | using Xtensive.Sql; |
12 | 10 | using Xtensive.Sql.Dml; |
13 | 11 | using Xtensive.Sql.Drivers.PostgreSql.v8_0; |
14 | | -using Xtensive.Sql.Model; |
15 | 12 |
|
16 | 13 | namespace Xtensive.Orm.Tests.Sql.PostgreSql |
17 | 14 | { |
18 | 15 | public class ExtractorTest: ExtractorTestBase |
19 | 16 | { |
20 | 17 | protected override bool CheckContstraintExtracted => true; |
21 | | - protected override bool SeqStartEqualsToMin => true; |
22 | 18 |
|
23 | 19 | protected override void CheckRequirements() => Require.ProviderIs(StorageProvider.PostgreSql); |
24 | 20 |
|
@@ -89,12 +85,12 @@ protected override string GetForeignKeyExtractionPrepareScript() |
89 | 85 | " REFERENCES \"B3\" (\"b_id_1\", \"b_id_2\", \"b_id_3\") ON DELETE NO ACTION ON UPDATE CASCADE);"; |
90 | 86 | } |
91 | 87 | protected override string GetForeignKeyExtractionCleanUpScript() => |
92 | | - "drop table \"A1\"" + |
93 | | - "\n drop table \"A2\"" + |
94 | | - "\n drop table \"A3\"" + |
95 | | - "\n drop table \"B1\"" + |
96 | | - "\n drop table \"B2\"" + |
97 | | - "\n drop table \"B3\""; |
| 88 | + "drop table \"A1\";" + |
| 89 | + "\n drop table \"A2\";" + |
| 90 | + "\n drop table \"A3\";" + |
| 91 | + "\n drop table \"B1\";" + |
| 92 | + "\n drop table \"B2\";" + |
| 93 | + "\n drop table \"B3\";"; |
98 | 94 |
|
99 | 95 | protected override string GetIndexExtractionPrepareScript(string tableName) |
100 | 96 | { |
@@ -172,25 +168,33 @@ public void ExtractDateTimeOffsetFields() |
172 | 168 | var testTable = defaultSchema.Tables["InteractionLog"]; |
173 | 169 | var tableColumn = testTable.TableColumns["DateTimeOffset0"]; |
174 | 170 | Assert.That(tableColumn.DataType.Type, Is.EqualTo(SqlType.DateTimeOffset)); |
175 | | - Assert.That(tableColumn.DefaultValue, Is.EqualTo(new SqlNative("'0001-01-01 00:00:00+00:00'::timestamp(0) with time zone"))); |
| 171 | + Assert.That(tableColumn.DefaultValue, Is.InstanceOf<SqlNative>()); |
| 172 | + var defaultExpression = (SqlNative) tableColumn.DefaultValue; |
| 173 | + Assert.That(defaultExpression.Value, Is.EqualTo("'0001-01-01 04:02:33+04:02:33'::timestamp(0) with time zone")); |
176 | 174 |
|
177 | 175 | tableColumn = testTable.TableColumns["DateTimeOffset1"]; |
178 | 176 | Assert.That(tableColumn.DataType.Type, Is.EqualTo(SqlType.DateTimeOffset)); |
179 | | - Assert.That(tableColumn.DefaultValue, Is.EqualTo(new SqlNative("'0001-01-01 00:00:00.0+00:00'::timestamp(1) with time zone"))); |
| 177 | + Assert.That(tableColumn.DefaultValue, Is.InstanceOf<SqlNative>()); |
| 178 | + defaultExpression = (SqlNative) tableColumn.DefaultValue; |
| 179 | + Assert.That(defaultExpression.Value, Is.EqualTo("'0001-01-01 04:02:33+04:02:33'::timestamp(1) with time zone")); |
180 | 180 |
|
181 | 181 | tableColumn = testTable.TableColumns["DateTimeOffset2"]; |
182 | 182 | Assert.That(tableColumn.DataType.Type, Is.EqualTo(SqlType.DateTimeOffset)); |
183 | | - Assert.That(tableColumn.DefaultValue, Is.EqualTo(new SqlNative("'0001-01-01 00:00:00.00+00:00'::timestamp(2) with time zone"))); |
| 183 | + Assert.That(tableColumn.DefaultValue, Is.InstanceOf<SqlNative>()); |
| 184 | + defaultExpression = (SqlNative) tableColumn.DefaultValue; |
| 185 | + Assert.That(defaultExpression.Value, Is.EqualTo("'0001-01-01 04:02:33+04:02:33'::timestamp(2) with time zone")); |
184 | 186 |
|
185 | 187 | tableColumn = testTable.TableColumns["DateTimeOffset3"]; |
186 | 188 | Assert.That(tableColumn.DataType.Type, Is.EqualTo(SqlType.DateTimeOffset)); |
187 | | - Assert.That(tableColumn.DefaultValue, Is.EqualTo(new SqlNative("'0001-01-01 00:00:00.000+00:00'::timestamp(3) with time zone"))); |
| 189 | + Assert.That(tableColumn.DefaultValue, Is.InstanceOf<SqlNative>()); |
| 190 | + defaultExpression = (SqlNative) tableColumn.DefaultValue; |
| 191 | + Assert.That(defaultExpression.Value, Is.EqualTo("'0001-01-01 04:02:33+04:02:33'::timestamp(3) with time zone")); |
188 | 192 | } |
189 | 193 |
|
190 | 194 |
|
191 | 195 | protected virtual string GetExpressionIndexExtractorPrepareScript(string tableName) |
192 | 196 | { |
193 | | - return $"CREATE TABLE \" {tableName} \"(col1 text, col2 text);" + |
| 197 | + return $"CREATE TABLE \"{tableName}\"(col1 text, col2 text);" + |
194 | 198 | $"CREATE INDEX \"{tableName}_indx\" ON \"" + tableName + "\"(col1,col2,(col1||col2));"; |
195 | 199 | } |
196 | 200 |
|
|
0 commit comments