@@ -58,11 +58,6 @@ public static OracleOrmLiteDialectProvider Instance
58
58
get { return _instance ?? ( _instance = new OracleOrmLiteDialectProvider ( ) ) ; }
59
59
}
60
60
61
- //protected bool CompactGuid;
62
-
63
- //internal const string StringGuidDefinition = "VARCHAR2(37)";
64
- //internal const string CompactGuidDefinition = "RAW(16)";
65
-
66
61
private readonly DbProviderFactory _factory ;
67
62
private readonly OracleTimestampConverter _timestampConverter ;
68
63
@@ -78,24 +73,10 @@ public OracleOrmLiteDialectProvider(bool compactGuid, bool quoteNames, string cl
78
73
// Not nice to slow down, but need to read some types via Oracle-specific read methods so can't read all fields in single call
79
74
OrmLiteConfig . DeoptimizeReader = true ;
80
75
ClientProvider = clientProvider ;
81
- //CompactGuid = compactGuid;
82
76
QuoteNames = quoteNames ;
83
- //BoolColumnDefinition = "NUMBER(1)";
84
- //GuidColumnDefinition = CompactGuid ? CompactGuidDefinition : StringGuidDefinition;
85
- //LongColumnDefinition = "NUMERIC(18)";
86
77
AutoIncrementDefinition = string . Empty ;
87
- //DateTimeColumnDefinition = "TIMESTAMP";
88
- //DateTimeOffsetColumnDefinition = "TIMESTAMP WITH TIME ZONE";
89
- //TimeColumnDefinition = LongColumnDefinition;
90
- //RealColumnDefinition = "FLOAT";
91
- // Order-dependency here: must set following values before setting DefaultStringLength
92
- //StringLengthNonUnicodeColumnDefinitionFormat = "VARCHAR2({0})";
93
- //StringLengthUnicodeColumnDefinitionFormat = "NVARCHAR2({0})";
94
- //MaxStringColumnDefinition = StringLengthNonUnicodeColumnDefinitionFormat.Fmt(MaxStringColumnLength);
95
- //DefaultStringLength = 128;
96
78
97
79
ParamString = ":" ;
98
- // OrmLiteConfig.UseParameterizeSqlExpressions = true;
99
80
100
81
NamingStrategy = new OracleNamingStrategy ( MaxNameLength ) ;
101
82
ExecFilter = new OracleExecFilter ( ) ;
@@ -138,37 +119,6 @@ public OracleOrmLiteDialectProvider(bool compactGuid, bool quoteNames, string cl
138
119
} ;
139
120
}
140
121
141
- //public override void OnAfterInitColumnTypeMap()
142
- //{
143
- // base.OnAfterInitColumnTypeMap();
144
-
145
- // DbTypeMap.Set<bool>(DbType.Int16, BoolColumnDefinition);
146
- // DbTypeMap.Set<bool?>(DbType.Int16, BoolColumnDefinition);
147
-
148
- // DbTypeMap.Set<sbyte>(DbType.Int16, IntColumnDefinition);
149
- // DbTypeMap.Set<sbyte?>(DbType.Int16, IntColumnDefinition);
150
- // DbTypeMap.Set<ushort>(DbType.Int32, IntColumnDefinition);
151
- // DbTypeMap.Set<ushort?>(DbType.Int32, IntColumnDefinition);
152
- // DbTypeMap.Set<uint>(DbType.Int64, LongColumnDefinition);
153
- // DbTypeMap.Set<uint?>(DbType.Int64, LongColumnDefinition);
154
- // DbTypeMap.Set<ulong>(DbType.Int64, LongColumnDefinition);
155
- // DbTypeMap.Set<ulong?>(DbType.Int64, LongColumnDefinition);
156
-
157
- // if (CompactGuid)
158
- // {
159
- // DbTypeMap.Set<Guid>(DbType.Binary, GuidColumnDefinition);
160
- // DbTypeMap.Set<Guid?>(DbType.Binary, GuidColumnDefinition);
161
- // }
162
- // else
163
- // {
164
- // DbTypeMap.Set<Guid>(DbType.String, GuidColumnDefinition);
165
- // DbTypeMap.Set<Guid?>(DbType.String, GuidColumnDefinition);
166
- // }
167
-
168
- // DbTypeMap.Set<DateTimeOffset>(DbType.String, DateTimeOffsetColumnDefinition);
169
- // DbTypeMap.Set<DateTimeOffset?>(DbType.String, DateTimeOffsetColumnDefinition);
170
- //}
171
-
172
122
protected string ClientProvider = OdpProvider ;
173
123
public static string RowVersionTriggerFormat = "{0}RowVersionUpdateTrigger" ;
174
124
@@ -225,203 +175,6 @@ public override long InsertAndGetLastInsertId<T>(IDbCommand dbCmd)
225
175
return Convert . ToInt64 ( identityParameter . Value ) ;
226
176
}
227
177
228
- //Moved to converters.FromDbValue()
229
- //public override void SetDbValue(FieldDefinition fieldDef, IDataReader reader, int colIndex, object instance)
230
- //{
231
- // if (OrmLiteUtils.HandledDbNullValue(fieldDef, reader, colIndex, instance)) return;
232
-
233
- // var value = reader.GetValue(colIndex);
234
- // var convertedValue = ConvertDbValue(value, fieldDef.FieldType);
235
-
236
- // try
237
- // {
238
- // fieldDef.SetValueFn(instance, convertedValue);
239
- // }
240
- // catch (NullReferenceException ex)
241
- // {
242
- // Log.Warn("Unexpected NullReferenceException", ex);
243
- // }
244
- //}
245
-
246
- //Moved to converters.FromDbValue()
247
- //public override object ConvertDbValue(object value, Type type)
248
- //{
249
- // if (value == null || value is DBNull) return null;
250
-
251
- // if (type == typeof (DateTimeOffset))
252
- // {
253
- // return Convert.ChangeType(value, type);
254
- // }
255
-
256
- // if (type == typeof(bool))
257
- // return Convert.ToBoolean(value);
258
-
259
- // if (type == typeof(Guid))
260
- // {
261
- // if (CompactGuid)
262
- // {
263
- // var raw = (byte[])value;
264
- // return new Guid(raw);
265
- // }
266
- // return new Guid(value.ToString());
267
- // }
268
-
269
- // if (type == typeof(byte[]))
270
- // return value;
271
-
272
- // if (type == typeof(TimeSpan))
273
- // {
274
- // var ticks = long.Parse(value.ToString());
275
- // return TimeSpan.FromTicks(ticks);
276
- // }
277
-
278
- // return base.ConvertDbValue(value, type);
279
- //}
280
-
281
- //Moved to Converters.ToQuotedString()
282
- //public override string GetQuotedValue(object value, Type fieldType)
283
- //{
284
- // if (value == null) return "NULL";
285
-
286
- // if (fieldType == typeof(Guid))
287
- // {
288
- // var guid = (Guid)value;
289
- // return CompactGuid ? string.Format("CAST('{0}' AS {1})", BitConverter.ToString(guid.ToByteArray()).Replace("-", ""), CompactGuidDefinition)
290
- // : string.Format("CAST('{0}' AS {1})", guid, StringGuidDefinition);
291
- // }
292
-
293
- // if (fieldType == typeof(DateTime) || fieldType == typeof(DateTime?))
294
- // {
295
- // return GetQuotedDateTimeValue((DateTime)value);
296
- // }
297
-
298
- // if (fieldType == typeof(DateTimeOffset) || fieldType == typeof(DateTimeOffset?))
299
- // {
300
- // return GetQuotedDateTimeOffsetValue((DateTimeOffset)value);
301
- // }
302
-
303
- // if ((value is TimeSpan) && (fieldType == typeof(Int64) || fieldType == typeof(Int64?)))
304
- // {
305
- // var longValue = ((TimeSpan)value).Ticks;
306
- // return base.GetQuotedValue(longValue, fieldType);
307
- // }
308
-
309
- // if (fieldType == typeof(bool?) || fieldType == typeof(bool))
310
- // {
311
- // var boolValue = (bool)value;
312
- // return base.GetQuotedValue(boolValue ? "1" : "0", typeof(string));
313
- // }
314
-
315
- // if (fieldType == typeof(decimal?) || fieldType == typeof(decimal) ||
316
- // fieldType == typeof(double?) || fieldType == typeof(double) ||
317
- // fieldType == typeof(float?) || fieldType == typeof(float))
318
- // {
319
- // var s = base.GetQuotedValue(value, fieldType);
320
- // if (s.Length > 20) s = s.Substring(0, 20);
321
- // return "'" + s + "'"; // when quoted exception is more clear!
322
- // }
323
-
324
- // //Moved to OracleEnumConverter.ToQuotedString()
325
- // if (fieldType.IsEnum)
326
- // {
327
- // if (value is int && !fieldType.IsEnumFlags())
328
- // {
329
- // value = fieldType.GetEnumName(value);
330
- // }
331
-
332
- // var enumValue = StringSerializer.SerializeToString(value);
333
- // // Oracle stores empty strings in varchar columns as null so match that behavior here
334
- // if (enumValue == null)
335
- // return null;
336
- // enumValue = GetQuotedValue(enumValue.Trim('"'));
337
- // return enumValue == "''"
338
- // ? "null"
339
- // : enumValue;
340
- // }
341
-
342
- // if (fieldType == typeof(byte[]))
343
- // {
344
- // return "hextoraw('" + BitConverter.ToString((byte[])value).Replace("-", "") + "')";
345
- // }
346
-
347
- // return base.GetQuotedValue(value, fieldType);
348
- //}
349
-
350
- //Moved to Converters.ToDbParamValue()
351
- //public override object GetParamValue(object value, Type fieldType)
352
- //{
353
- // if (value == null) return "NULL";
354
-
355
- // if (fieldType == typeof(Guid))
356
- // {
357
- // var guid = (Guid)value;
358
-
359
- // if (CompactGuid)
360
- // return guid.ToByteArray();
361
-
362
- // return guid.ToString();
363
- // }
364
-
365
- // if (fieldType == typeof(DateTimeOffset) || fieldType == typeof(DateTimeOffset?))
366
- // {
367
- // return GetQuotedDateTimeOffsetValue((DateTimeOffset)value);
368
- // }
369
-
370
- // if ((value is TimeSpan) && (fieldType == typeof(Int64) || fieldType == typeof(Int64?)))
371
- // {
372
- // var longValue = ((TimeSpan)value).Ticks;
373
- // return base.GetQuotedValue(longValue, fieldType);
374
- // }
375
-
376
- // if (fieldType == typeof(TimeSpan))
377
- // return ((TimeSpan)value).Ticks;
378
-
379
- // if (fieldType == typeof(bool?) || fieldType == typeof(bool))
380
- // {
381
- // var boolValue = (bool)value;
382
- // return boolValue ? 1 : 0;
383
- // }
384
-
385
- // //Moved to OracleEnumConverter.ToDbParamValue()
386
- // if (fieldType.IsEnum)
387
- // {
388
- // if (value is int && !fieldType.IsEnumFlags())
389
- // {
390
- // value = fieldType.GetEnumName(value);
391
- // }
392
-
393
- // var enumValue = StringSerializer.SerializeToString(value);
394
- // // Oracle stores empty strings in varchar columns as null so match that behavior here
395
- // if (enumValue == null)
396
- // return null;
397
- // enumValue = enumValue.Trim('"');
398
- // return enumValue == ""
399
- // ? "null"
400
- // : enumValue;
401
- // }
402
-
403
- // if (fieldType == typeof(byte[]))
404
- // {
405
- // return "hextoraw('" + BitConverter.ToString((byte[])value).Replace("-", "") + "')";
406
- // }
407
-
408
- // //override default by setting base.ReferenceTypeConverter
409
- // if (fieldType.IsRefType())
410
- // {
411
- // return StringSerializer.SerializeToString(value);
412
- // }
413
-
414
- // switch (fieldType.GetTypeCode())
415
- // {
416
- // case TypeCode.UInt16:
417
- // case TypeCode.UInt32:
418
- // case TypeCode.UInt64:
419
- // return Convert.ToDecimal(value);
420
- // }
421
-
422
- // return value;
423
- //}
424
-
425
178
public override object ToDbValue ( object value , Type type )
426
179
{
427
180
if ( value == null || value is DBNull )
@@ -624,35 +377,6 @@ public override void SetParameterValues<T>(IDbCommand dbCmd, object obj)
624
377
}
625
378
}
626
379
627
- // TODO: do we need this?
628
- public override void SetParameterValue < T > ( FieldDefinition fieldDef , IDataParameter p , object obj )
629
- {
630
- p . Value = GetValueOrDbNull < T > ( fieldDef , obj ) ;
631
- }
632
-
633
- //Moved to Converters.ToDbValue()
634
- //protected override object GetValue<T>(FieldDefinition fieldDef, object obj)
635
- //{
636
- // var value = base.GetValue<T>(fieldDef, obj);
637
-
638
- // if (value != null)
639
- // {
640
- // if (fieldDef.FieldType == typeof(Guid))
641
- // {
642
- // var guid = (Guid)value;
643
- // if (CompactGuid) return guid.ToByteArray();
644
- // return guid.ToString();
645
- // }
646
-
647
- // if (fieldDef.FieldType == typeof(DateTimeOffset))
648
- // {
649
- // var timestamp = (DateTimeOffset)value;
650
- // return _timestampConverter.ConvertToOracleTimeStampTz(timestamp);
651
- // }
652
- // }
653
- // return value;
654
- //}
655
-
656
380
//TODO: Change to parameterized query to match all other ToInsertRowStatement() impls
657
381
public override string ToInsertRowStatement ( IDbCommand dbCommand , object objWithProperties , ICollection < string > insertFields = null )
658
382
{
@@ -1212,7 +936,7 @@ public override bool DoesTableExist(IDbCommand dbCmd, string tableName, string s
1212
936
if ( ! WillQuote ( tableName ) ) tableName = tableName . ToUpper ( ) ;
1213
937
1214
938
tableName = RemoveSchemaName ( tableName ) ;
1215
- var sql = "SELECT count(*) FROM ALL_TABLES WHERE TABLE_NAME = {0}" . SqlFmt ( tableName ) ;
939
+ var sql = "SELECT count(*) FROM USER_TABLES WHERE TABLE_NAME = {0}" . SqlFmt ( tableName ) ;
1216
940
1217
941
if ( schema != null )
1218
942
sql += " AND OWNER = {0}" . SqlFmt ( schema ) ;
0 commit comments