DBFlow icon indicating copy to clipboard operation
DBFlow copied to clipboard

Typo in OrderBy Clause: "DSC" Should Be "DESC" in SQLite

Open jparkie opened this issue 12 years ago • 1 comments

In DBFlow / library / src / main / java / com / grosner / dbflow / sql / language / Where.java at Where.java, I found an error with orderBy. As per https://www.sqlite.org/lang_select.html, it is not DSC, but DESC.

    /**
     * Defines a SQL ORDER BY statement without the ORDER BY.
     *
     * @param ascending If we should be in ascending order
     * @return
     */
    public Where<ModelClass> orderBy(boolean ascending, String... columns) {
        mOrderBy = new QueryBuilder().appendArray(columns).appendSpace().append(ascending ? "ASC" : "DSC").getQuery();
        return this;
    }

This should be the following:

    /**
     * Defines a SQL ORDER BY statement without the ORDER BY.
     *
     * @param ascending If we should be in ascending order
     * @return
     */
    public Where<ModelClass> orderBy(boolean ascending, String... columns) {
        mOrderBy = new QueryBuilder().appendArray(columns).appendSpace().append(ascending ? "ASC" : "DESC").getQuery();
        return this;
    }

Otherwise, you get an error like this:

E/SQLiteLog﹕ (1) near "DSC": syntax error

jparkie avatar Nov 25 '14 04:11 jparkie

@jparkie good find! will be in 1.0.2 within the hour

agrosner avatar Nov 25 '14 12:11 agrosner