1- // Copyright (C) 2003-2010 Xtensive LLC.
2- // All rights reserved .
3- // For conditions of distribution and use, see license .
1+ // Copyright (C) 2011-2021 Xtensive LLC.
2+ // This code is distributed under MIT license terms .
3+ // See the License.txt file in the project root for more information .
44// Created by: Csaba Beer
55// Created: 2011.01.13
66
@@ -84,11 +84,10 @@ private void ExtractTables()
8484
8585 private void ExtractTableColumns ( )
8686 {
87- using (
88- var reader = Connection . CreateCommand ( GetExtractTableColumnsQuery ( ) ) . ExecuteReader ( CommandBehavior . SingleResult )
89- ) {
87+ using ( var command = Connection . CreateCommand ( GetExtractTableColumnsQuery ( ) ) )
88+ using ( var reader = command . ExecuteReader ( CommandBehavior . SingleResult ) ) {
9089 Table table = null ;
91- int lastColumnId = int . MaxValue ;
90+ var lastColumnId = int . MaxValue ;
9291 while ( reader . Read ( ) ) {
9392 int columnSeq = reader . GetInt16 ( 2 ) ;
9493 if ( columnSeq <= lastColumnId ) {
@@ -99,8 +98,16 @@ private void ExtractTableColumns()
9998 column . DataType = CreateValueType ( reader , 4 , 5 , 7 , 8 , 9 ) ;
10099 column . IsNullable = ReadBool ( reader , 10 ) ;
101100 var defaultValue = ReadStringOrNull ( reader , 11 ) ;
102- if ( ! string . IsNullOrEmpty ( defaultValue ) )
103- column . DefaultValue = SqlDml . Native ( defaultValue ) ;
101+ if ( ! string . IsNullOrEmpty ( defaultValue ) ) {
102+ defaultValue = defaultValue . TrimStart ( ' ' ) ;
103+ if ( defaultValue . StartsWith ( "DEFAULT" , StringComparison . OrdinalIgnoreCase ) ) {
104+ defaultValue = defaultValue . Substring ( 7 ) . TrimStart ( ' ' ) ;
105+ }
106+ if ( ! string . IsNullOrEmpty ( defaultValue ) ) {
107+ column . DefaultValue = SqlDml . Native ( defaultValue ) ;
108+ }
109+ }
110+
104111 lastColumnId = columnSeq ;
105112 }
106113 }
0 commit comments