Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a way to define primary and secondary XML Indexes #1624

Open
ashishs opened this issue Nov 7, 2022 · 3 comments
Open

Provide a way to define primary and secondary XML Indexes #1624

ashishs opened this issue Nov 7, 2022 · 3 comments

Comments

@ashishs
Copy link

ashishs commented Nov 7, 2022

Exposed currently has no way to define xml indexes in MS SQL Server.

E.g:

CREATE PRIMARY XML INDEX [primary_xml_index_name] ON [table_name]([xml_column_1])

CREATE XML INDEX secondary_xml_index_name ON [table_name]([xml_column_1]) USING XML INDEX [primary_xml_index_name] FOR VALUE

Secondary xml indexes can be on PATH, VALUE, or PROPERTY
Documentation at XML Indexes

Note: a probable fix is to allow a listOf < DdlAware > objects to be added ad-hoc to a Table and have run after the table is created. The Index class is defined as a data class which prohibits subclassing.

@AlexeySoshin
Copy link
Contributor

Hi @ashishs
This seems a very DB-specific feature to me.
My suggestion would be to implement this using a prepared statement instead.

@ashishs
Copy link
Author

ashishs commented Nov 15, 2022

@AlexeySoshin Even if this is created using a prepared statement, ther create missing columns method of the SchemaUtils breaks this. This happens in the code where indexes are checked. So creating the schema from code is not possible if XML indexes are used.

@bog-walk
Copy link
Member

@ashishs Regarding primary xml indexes, as a start, could you please confirm if creating it by leveraging indexType works?

val tester = object : Table("tester") {
    val id = integer("id")
    val primaryXml = xml("primary_xml_column") // assumes a custom column type
    
    override val primaryKey = PrimaryKey(id)
    
    init {
        index("primary_xml_index", false, primaryXml, indexType = "PRIMARY XML")
    }
}
// generates SQL
CREATE TABLE tester (id INT PRIMARY KEY, primary_xml_column XML NOT NULL)
CREATE PRIMARY XML INDEX primary_xml_index ON tester (primary_xml_column)

If this doesn't work for you, please consider providing the exception you're getting, as well as how the xml column type is declared and registered for use, so we can take a further look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants