File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1138,7 +1138,8 @@ public override int GetOrdinal(string name)
11381138
11391139 /// <summary>
11401140 /// Gets the data type information for the specified field.
1141- /// This will be the Postgresql type name (e.g. int4), not the .NET type (<see cref="GetFieldType"/>)
1141+ /// This will be the PostgreSQL type name (e.g. int4) as in the pg_type table,
1142+ /// not the .NET type (see <see cref="GetFieldType"/> for that).
11421143 /// </summary>
11431144 /// <param name="ordinal"></param>
11441145 /// <returns></returns>
Original file line number Diff line number Diff line change @@ -342,7 +342,7 @@ void RegisterArrayType(BackendType backendType)
342342 arrayHandler = ( TypeHandler ) Activator . CreateInstance ( arrayHandlerType , elementHandler ) ;
343343 }
344344
345- arrayHandler . PgName = "array" ;
345+ arrayHandler . PgName = backendType . Name ;
346346 arrayHandler . OID = backendType . OID ;
347347 OIDIndex [ backendType . OID ] = arrayHandler ;
348348
Original file line number Diff line number Diff line change @@ -198,13 +198,21 @@ public void GetValueByName()
198198 }
199199
200200 [ Test ]
201+ [ IssueLink ( "https://github.com/npgsql/npgsql/issues/787" ) ]
201202 public void GetDataTypeName ( )
202203 {
203- var command = new NpgsqlCommand ( @"SELECT 1::INT4 AS some_column" , Conn ) ;
204- var dr = command . ExecuteReader ( ) ;
205- dr . Read ( ) ;
206- Assert . That ( dr . GetDataTypeName ( 0 ) , Is . EqualTo ( "int4" ) ) ;
207- command . Dispose ( ) ;
204+ using ( var command = new NpgsqlCommand ( @"SELECT 1::INT4 AS some_column" , Conn ) )
205+ using ( var reader = command . ExecuteReader ( ) )
206+ {
207+ reader . Read ( ) ;
208+ Assert . That ( reader . GetDataTypeName ( 0 ) , Is . EqualTo ( "int4" ) ) ;
209+ }
210+ using ( var command = new NpgsqlCommand ( @"SELECT '{1}'::INT4[] AS some_column" , Conn ) )
211+ using ( var reader = command . ExecuteReader ( ) )
212+ {
213+ reader . Read ( ) ;
214+ Assert . That ( reader . GetDataTypeName ( 0 ) , Is . EqualTo ( "_int4" ) ) ;
215+ }
208216 }
209217
210218 [ Test ]
You can’t perform that action at this time.
0 commit comments