public PlatformTableSourceColumnInfo(ITableSourceInfo tableSource, string name, IPlatformDataTypeInfo dataType, bool isMandatory, bool isPrimaryKey, AutoNumberColumnInfo autoNumberInfo) : base(tableSource, name, dataType, isMandatory, isPrimaryKey, autoNumberInfo) { }
protected IEnumerable <ITableSourceColumnInfo> GetColumns(IEnumerable <TableSourceInfo> tableSources, DatabaseInfo dbInfo, CreateAutoNumberInfo createAutoNumber, CreateDataTypeInfo createDataType, CreateColumnInfo createColumnInfo) { var result = new List <ITableSourceColumnInfo>(); using (IDbConnection conn = DatabaseServices.TransactionService.CreateConnection()) { var execService = DatabaseServices.ExecutionService as ExecutionService.ExecutionService; // #417717 - In these queries we don't want to use the CIAI settings if (execService != null) { execService.ForceCSASSetting(conn); } IDictionary <string, AutoNumberColumnInfo> autoGeneratedColumns = new Dictionary <string, AutoNumberColumnInfo>(); IList <TableSourceInfo> tableSourceList = tableSources.ToList(); using (IDataReader reader = GetTriggersBulk(conn, tableSourceList, /*onlyAutoNumbers*/ true, String.Empty, dbInfo)) { while (reader.Read()) { string tableName = Convert.ToString(reader["TABLE_NAME"]); if (autoGeneratedColumns.ContainsKey(tableName)) { break; } string triggerName = Convert.ToString(reader["trigger_name"]).ToUpperInvariant(); string triggerBody = Convert.ToString(reader["trigger_body"]).ToUpperInvariant(); string triggerType = Convert.ToString(reader["trigger_type"]).ToUpperInvariant(); string triggeringEvent = Convert.ToString(reader["triggering_event"]).ToUpperInvariant(); var autoNumberInfo = createAutoNumber(triggerType, triggeringEvent, triggerName, triggerBody); if (autoNumberInfo != null) { autoGeneratedColumns[GetAutoNumberColumnKey(tableName, autoNumberInfo.ColumnName)] = autoNumberInfo; } } } using (IDataReader reader = GetColumnsBulk(conn, tableSourceList, dbInfo)) { while (reader.Read()) { // WARNING: // Do not change the order of these variables. In Java, columns of type Long and Long Raw must be read before the others (DATA_DEFAULT must be first). // Read more here: https://blog.jooq.org/2015/12/30/oracle-long-and-long-raw-causing-stream-has-already-been-closed-exception/ string dataDefault = Convert.ToString(reader["DATA_DEFAULT"]); string tableName = Convert.ToString(reader["TABLE_NAME"]); string columnName = Convert.ToString(reader["COLUMN_NAME"]); object constraintType = reader["CONSTRAINT_TYPE"]; object dataPrecision = reader["DATA_PRECISION"]; object dataScale = reader["DATA_SCALE"]; bool isMandatory = Convert.ToString(reader["NULLABLE"]).ToUpper() != "Y"; bool isPrimaryKey = !constraintType.Equals(DBNull.Value) && Convert.ToString(constraintType) == "P"; int precision = dataPrecision.Equals(DBNull.Value) ? 0 : Convert.ToInt32(dataPrecision); int scale = dataScale.Equals(DBNull.Value) ? 0 : Convert.ToInt32(dataScale); DataTypeInfo dataType = createDataType(Convert.ToString(reader["DATA_TYPE"]), Convert.ToInt32(reader["CHAR_LENGTH"]), precision, scale); AutoNumberColumnInfo autoNumberInfo; autoGeneratedColumns.TryGetValue(GetAutoNumberColumnKey(tableName, columnName), out autoNumberInfo); if (autoNumberInfo == null) // For versions above 12c (12.1) autonumbers can be generated via identity or sequences { if (IsSequenceValue(dataDefault)) { autoNumberInfo = new AutoNumberColumnInfo() { ColumnName = columnName }; } } TableSourceInfo tableSource = tableSourceList.First(ts => ts.Name.EqualsIgnoreCase(tableName)); result.Add(createColumnInfo(tableSource, columnName, dataType, isMandatory, isPrimaryKey, autoNumberInfo)); } } } return(result); }
private static TableSourceColumnInfo GetColumnInfo(TableSourceInfo tableSource, string columnName, DataTypeInfo dataType, bool isMandatory, bool isPrimaryKey, AutoNumberColumnInfo autoNumberInfo) { return(new TableSourceColumnInfo(tableSource, columnName, dataType, isMandatory, isPrimaryKey, autoNumberInfo != null)); }
private static PlatformTableSourceColumnInfo GetPlatformColumnInfo(TableSourceInfo tableSource, string columnName, DataTypeInfo dataType, bool isMandatory, bool isPrimaryKey, AutoNumberColumnInfo autoNumberInfo) { return(new PlatformTableSourceColumnInfo(tableSource, columnName, (PlatformDataTypeInfo)dataType, isMandatory, isPrimaryKey, autoNumberInfo)); }