Class CosmosSqlQuery

    • Nested Class Summary

      • Nested classes/interfaces inherited from class io.inversion.jdbc.SqlQuery

        io.inversion.jdbc.SqlQuery.Parts
    • Field Summary

      • Fields inherited from class io.inversion.jdbc.SqlQuery

        columnQuote, stringQuote
      • Fields inherited from class io.inversion.query.Query

        castValues, collection, db, dryRun, from, group, order, originalValues, page, select, where
      • Fields inherited from class io.inversion.query.Builder

        builders, functions, parent, terms
    • Constructor Summary

      Constructors 
      Constructor Description
      CosmosSqlQuery​(CosmosDb db, io.inversion.Collection table, java.util.List<io.inversion.rql.Term> terms)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected java.lang.String asString​(io.inversion.rql.Term term)
      Overridden to exclude rdbms style '%' wildcards that are not needed for cosmos sw and ew queries.
      protected java.lang.String asVariableName​(int valuesPairIdx)
      Cosmos does not use "?" ansi sql style prepared statement vars, it uses named variables prefixed with '@'.
      protected io.inversion.query.Where createWhere()  
      io.inversion.Results doSelect()  
      protected java.util.List<io.inversion.query.Order.Sort> getDefaultSorts​(io.inversion.jdbc.SqlQuery.Parts parts)
      The inversion configured primary index should contain at least the document identifier and the partition key.
      protected java.lang.String printExpression​(io.inversion.rql.Term term, java.util.List<java.lang.String> dynamicSqlChildText, java.util.List<java.lang.String> preparedStmtChildText)  
      protected java.lang.String printLimitClause​(io.inversion.jdbc.SqlQuery.Parts parts, int offset, int limit)
      Both offset and limit are required per cosmos spec.
      protected java.lang.String toSql​(boolean preparedStmt)
      Makes a few blanked tweaks to the sql created by the SqlQuery superclass to make it Cosmos compliant
      • Methods inherited from class io.inversion.jdbc.SqlQuery

        addTerm, asBool, asNum, asString, concatAll, getDynamicStmt, getPreparedStmt, getType, isBool, isCol, isNum, printCol, printGroupClause, printInitialSelect, printJoins, printOrderClause, printSql, printTableAlias, printTerm, printTermsSelect, printWhereClause, queryFoundRows, quoteCol, replace, withColumnQuote, withDb, withStringQuote, withType
      • Methods inherited from class io.inversion.query.Query

        clearValues, createFrom, createGroup, createOrder, createPage, createSelect, getBuilders, getCollection, getColValue, getColValueKeys, getColValues, getDb, getFrom, getGroup, getNumValues, getOrder, getOriginalValues, getPage, getSelect, getValues, getWhere, isDryRun, withCollection, withColValue, withDryRun, withTerm
      • Methods inherited from class io.inversion.query.Builder

        clearFunctions, find, find, findAll, findAll, findInt, findTerm, getParent, getRoot, getTerms, isFunction, parse, r, removeBuilder, toString, toString, withBuilder, withFunctions, withFunctions, withParent, withTerm, withTerm, withTerms
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • CosmosSqlQuery

        public CosmosSqlQuery​(CosmosDb db,
                              io.inversion.Collection table,
                              java.util.List<io.inversion.rql.Term> terms)
    • Method Detail

      • createWhere

        protected io.inversion.query.Where createWhere()
        Overrides:
        createWhere in class io.inversion.query.Query<io.inversion.jdbc.SqlQuery,​CosmosDb,​io.inversion.query.Select<io.inversion.query.Select<io.inversion.query.Select,​io.inversion.jdbc.SqlQuery>,​io.inversion.jdbc.SqlQuery>,​io.inversion.query.From<io.inversion.query.From<io.inversion.query.From,​io.inversion.jdbc.SqlQuery>,​io.inversion.jdbc.SqlQuery>,​io.inversion.query.Where<io.inversion.query.Where<io.inversion.query.Where,​io.inversion.jdbc.SqlQuery>,​io.inversion.jdbc.SqlQuery>,​io.inversion.query.Group<io.inversion.query.Group<io.inversion.query.Group,​io.inversion.jdbc.SqlQuery>,​io.inversion.jdbc.SqlQuery>,​io.inversion.query.Order<io.inversion.query.Order<io.inversion.query.Order,​io.inversion.jdbc.SqlQuery>,​io.inversion.jdbc.SqlQuery>,​io.inversion.query.Page<io.inversion.query.Page<io.inversion.query.Page,​io.inversion.jdbc.SqlQuery>,​io.inversion.jdbc.SqlQuery>>
      • doSelect

        public io.inversion.Results doSelect()
                                      throws io.inversion.ApiException
        Overrides:
        doSelect in class io.inversion.jdbc.SqlQuery<CosmosDb>
        Throws:
        io.inversion.ApiException
      • toSql

        protected java.lang.String toSql​(boolean preparedStmt)
        Makes a few blanked tweaks to the sql created by the SqlQuery superclass to make it Cosmos compliant

        Replaces:

        • SELECT "table".* FROM "table" -@gt; SELECT * FROM table
        • "table"."column" -@gt; table["column"]
        Overrides:
        toSql in class io.inversion.jdbc.SqlQuery<CosmosDb>
        See Also:
        Cosmos Sql Query Select, Cosmos Sql Query - Quoted Property Accessor
      • getDefaultSorts

        protected java.util.List<io.inversion.query.Order.Sort> getDefaultSorts​(io.inversion.jdbc.SqlQuery.Parts parts)
        The inversion configured primary index should contain at least the document identifier and the partition key. If you don't supply a sort key on the query string that would default to adding two fields to the sort. If you did not configure cosmos to have a compound search index, that would fail...simply solution...if you did not supply a sort on the query string, just search by the "id" field.
        Overrides:
        getDefaultSorts in class io.inversion.jdbc.SqlQuery<CosmosDb>
      • printLimitClause

        protected java.lang.String printLimitClause​(io.inversion.jdbc.SqlQuery.Parts parts,
                                                    int offset,
                                                    int limit)
        Both offset and limit are required per cosmos spec.
        Overrides:
        printLimitClause in class io.inversion.jdbc.SqlQuery<CosmosDb>
        See Also:
        Cosmos Offset and Limit
      • asVariableName

        protected java.lang.String asVariableName​(int valuesPairIdx)
        Cosmos does not use "?" ansi sql style prepared statement vars, it uses named variables prefixed with '@'.
        Overrides:
        asVariableName in class io.inversion.jdbc.SqlQuery<CosmosDb>
      • asString

        protected java.lang.String asString​(io.inversion.rql.Term term)
        Overridden to exclude rdbms style '%' wildcards that are not needed for cosmos sw and ew queries.
        Overrides:
        asString in class io.inversion.jdbc.SqlQuery<CosmosDb>
        Returns:
        the term as a string approperiate for use in a cosmos query
      • printExpression

        protected java.lang.String printExpression​(io.inversion.rql.Term term,
                                                   java.util.List<java.lang.String> dynamicSqlChildText,
                                                   java.util.List<java.lang.String> preparedStmtChildText)
        Overrides:
        printExpression in class io.inversion.jdbc.SqlQuery<CosmosDb>