@@ -1183,6 +1183,63 @@ public async Task InsertPostgresSpecialTypes(InsertPostgresSpecialTypesArgs args
11831183 await this . Transaction . Connection . ExecuteAsync ( InsertPostgresSpecialTypesSql , queryParams , transaction : this . Transaction ) ;
11841184 }
11851185
1186+ private const string InsertPostgresNotNullTypesSql = "INSERT INTO postgres_not_null_types ( c_enum_not_null ) VALUES ( @c_enum_not_null::c_enum )" ;
1187+ public class InsertPostgresNotNullTypesArgs
1188+ {
1189+ public required CEnum CEnumNotNull { get ; init ; }
1190+ } ;
1191+ public async Task InsertPostgresNotNullTypes ( InsertPostgresNotNullTypesArgs args )
1192+ {
1193+ var queryParams = new Dictionary < string , object ? > ( ) ;
1194+ queryParams . Add ( "c_enum_not_null" , args . CEnumNotNull . Stringify ( ) ) ;
1195+ if ( this . Transaction == null )
1196+ {
1197+ using ( var connection = new NpgsqlConnection ( ConnectionString ) )
1198+ await connection . ExecuteAsync ( InsertPostgresNotNullTypesSql , queryParams ) ;
1199+ return ;
1200+ }
1201+
1202+ if ( this . Transaction ? . Connection == null || this . Transaction ? . Connection . State != System . Data . ConnectionState . Open )
1203+ throw new InvalidOperationException ( "Transaction is provided, but its connection is null." ) ;
1204+ await this . Transaction . Connection . ExecuteAsync ( InsertPostgresNotNullTypesSql , queryParams , transaction : this . Transaction ) ;
1205+ }
1206+
1207+ private const string GetPostgresNotNullTypesSql = "SELECT c_enum_not_null FROM postgres_not_null_types LIMIT 1" ;
1208+ public class GetPostgresNotNullTypesRow
1209+ {
1210+ public required CEnum CEnumNotNull { get ; init ; }
1211+ } ;
1212+ public async Task < GetPostgresNotNullTypesRow ? > GetPostgresNotNullTypes ( )
1213+ {
1214+ if ( this . Transaction == null )
1215+ {
1216+ using ( var connection = new NpgsqlConnection ( ConnectionString ) )
1217+ {
1218+ var result = await connection . QueryFirstOrDefaultAsync < GetPostgresNotNullTypesRow ? > ( GetPostgresNotNullTypesSql ) ;
1219+ return result ;
1220+ }
1221+ }
1222+
1223+ if ( this . Transaction ? . Connection == null || this . Transaction ? . Connection . State != System . Data . ConnectionState . Open )
1224+ throw new InvalidOperationException ( "Transaction is provided, but its connection is null." ) ;
1225+ return await this . Transaction . Connection . QueryFirstOrDefaultAsync < GetPostgresNotNullTypesRow ? > ( GetPostgresNotNullTypesSql , transaction : this . Transaction ) ;
1226+ }
1227+
1228+ private const string TruncatePostgresNotNullTypesSql = "TRUNCATE TABLE postgres_not_null_types" ;
1229+ public async Task TruncatePostgresNotNullTypes ( )
1230+ {
1231+ if ( this . Transaction == null )
1232+ {
1233+ using ( var connection = new NpgsqlConnection ( ConnectionString ) )
1234+ await connection . ExecuteAsync ( TruncatePostgresNotNullTypesSql ) ;
1235+ return ;
1236+ }
1237+
1238+ if ( this . Transaction ? . Connection == null || this . Transaction ? . Connection . State != System . Data . ConnectionState . Open )
1239+ throw new InvalidOperationException ( "Transaction is provided, but its connection is null." ) ;
1240+ await this . Transaction . Connection . ExecuteAsync ( TruncatePostgresNotNullTypesSql , transaction : this . Transaction ) ;
1241+ }
1242+
11861243 private const string GetPostgresSpecialTypesSql = "SELECT c_json, c_json_string_override, c_jsonb, c_jsonpath, c_xml, c_xml_string_override, c_uuid, c_enum FROM postgres_special_types LIMIT 1" ;
11871244 public class GetPostgresSpecialTypesRow
11881245 {
0 commit comments