public override string Translate(SqlCompilerContext context, SqlCreateIndex node, CreateIndexSection section) { Index index = node.Index; switch (section) { case CreateIndexSection.Entry: return(string.Format("CREATE {0} INDEX {1} ON {2} ", index.IsUnique ? "UNIQUE" : String.Empty, QuoteIdentifier(index.Name), QuoteIdentifier(index.DataTable.Name))); case CreateIndexSection.Exit: return(string.Empty); default: return(base.Translate(context, node, section)); } }
/// <inheritdoc/> public override string Translate(SqlCompilerContext context, SqlCreateIndex node, CreateIndexSection section) { switch (section) { case CreateIndexSection.Entry: Index index = node.Index; var builder = new StringBuilder(); builder.Append("CREATE "); if (index.IsUnique) { builder.Append("UNIQUE "); } //else if (!index.IsAscending) // builder.Append("DESC "); builder.Append("INDEX " + QuoteIdentifier(index.DbName)); builder.Append(" ON " + Translate(context, index.DataTable)); return(builder.ToString()); case CreateIndexSection.ColumnsEnter: if (node.Index.Columns[0].Expression != null) { if (node.Index.Columns.Count > 1) { SqlHelper.NotSupported("expression index with multiple column"); } return("COMPUTED BY ("); } else { return("("); } } return(base.Translate(context, node, section)); }
public override string Translate(SqlCompilerContext context, SqlCreateIndex node, CreateIndexSection section) { var baseSectionTranslation = base.Translate(context, node, section); if (section != CreateIndexSection.Exit) { return(baseSectionTranslation); } var index = node.Index; var ftIndex = index as FullTextIndex; if (ftIndex == null) { return(baseSectionTranslation); } if (ftIndex.FullTextCatalog != null) { baseSectionTranslation = baseSectionTranslation + " ON " + QuoteIdentifier(ftIndex.FullTextCatalog); } return(baseSectionTranslation + " WITH CHANGE_TRACKING " + TranslateChangeTrackingMode(ftIndex.ChangeTrackingMode)); }
public override string Translate(SqlCompilerContext context, SqlCreateIndex node, CreateIndexSection section) { Index index = node.Index; switch (section) { case CreateIndexSection.Entry: return(string.Format("CREATE {0}INDEX {1} ON {2} {3}(" , index.IsUnique ? "UNIQUE " : string.Empty , QuoteIdentifier(index.Name) , Translate(context, index.DataTable) , index.IsSpatial ? "USING GIST" : string.Empty)); case CreateIndexSection.StorageOptions: var builder = new StringBuilder(")"); AppendIndexStorageParameters(builder, index); if (!string.IsNullOrEmpty(index.Filegroup)) { _ = builder.Append(" TABLESPACE " + QuoteIdentifier(index.Filegroup)); } return(builder.ToString()); case CreateIndexSection.Exit: return(string.Empty); case CreateIndexSection.Where: return(" WHERE "); default: return(string.Empty); } }
public override string Translate(SqlCompilerContext context, SqlCreateIndex node, CreateIndexSection section) { var builder = new StringBuilder(); var index = node.Index; switch (section) { case CreateIndexSection.Entry: builder.Append("CREATE "); if (index.IsUnique) { builder.Append("UNIQUE "); } else if (index.IsBitmap) { builder.Append("BITMAP "); } builder.Append("INDEX "); builder.Append(Translate(index)); builder.Append(" ON "); builder.Append(Translate(context, index.DataTable)); return(builder.ToString()); case CreateIndexSection.Exit: break; case CreateIndexSection.ColumnsEnter: return("("); case CreateIndexSection.ColumnsExit: return(")"); case CreateIndexSection.NonkeyColumnsEnter: break; case CreateIndexSection.NonkeyColumnsExit: break; case CreateIndexSection.StorageOptions: break; case CreateIndexSection.Where: break; default: throw new ArgumentOutOfRangeException("section"); } return(string.Empty); }
public override string Translate(SqlCompilerContext context, SqlCreateIndex node, CreateIndexSection section) { var index = node.Index; if (!index.IsFullText) { return(base.Translate(context, node, section)); } switch (section) { case CreateIndexSection.Entry: return(string.Format("CREATE INDEX {0} ON {1} USING gin (" , QuoteIdentifier(index.Name) , Translate(context, index.DataTable))); case CreateIndexSection.ColumnsExit: // Add actual columns list return(string.Concat(GetFulltextVector(context, (FullTextIndex)node.Index), base.Translate(context, node, section))); default: return(base.Translate(context, node, section)); } }
public override string Translate(SqlCompilerContext context, Ddl.SqlCreateIndex node, CreateIndexSection section) { switch (section) { case CreateIndexSection.ColumnsExit: if (!node.Index.IsSpatial) { return(base.Translate(context, node, section)); } var table = node.Index.DataTable as Table; var column = table.TableColumns[node.Index.Columns[0].Name]; return(column.DataType.Type == CustomSqlType.Geometry ? ") USING GEOMETRY_GRID WITH ( BOUNDING_BOX = ( 0, 0, 500, 200))" : ") USING GEOGRAPHY_GRID"); } return(base.Translate(context, node, section)); }