Package com.redspr.redquerybuilder.core.client.command.dml

Examples of com.redspr.redquerybuilder.core.client.command.dml.Select


        String sql0 = "SELECT x.id FROM Person x"
            + " WHERE x.category NOT IN (?, ?)";
        List<Object> args0 = args("1", "2");
        CommandBuilder cb = new CommandBuilder(getSession(), sql0, args0);

        Select s = cb.getSelect();
        cb.fireDirty(); // XXX encapsulation

        // collect initial non-sense...
        String sql1 = "SELECT X.ID\nFROM PERSON X\n"
            + "WHERE (X.CATEGORY NOT IN (?, ?))";
        List<Object> args1 = new ArrayList<Object>();
        assertEquals(sql1, s.getSQL(args1));
        assertEquals(args0, args1);
    }
View Full Code Here


        String sql0 = "SELECT x.id FROM Person x"
            + " WHERE x.category IN (NULL)";

        Prepared prep = p.parseOnly(sql0);

        Select s = (Select) prep;

        // collect initial non-sense...
        String sql1 = "SELECT X.ID\nFROM PERSON X\n"
            + "WHERE (X.CATEGORY IN (NULL))";
        List args = args();
        assertEquals(sql1, s.getSQL(args));
        assertEquals(0, args.size());
    }
View Full Code Here

        String sql0 = "SELECT x.id FROM Person x"
                + " WHERE x.category IN (?, ?)";
        CommandBuilder cb = new CommandBuilder(sess, sql0, args("A", "B"));
        RootPanel.get().add(cb);
        Select s = cb.getSelect();

        cb.fireDirty();

        {
            Comparison comp = (Comparison) s.getCondition();
            Parameter right = (Parameter) comp.getRight();
            Element selectElmt = right.getElement();

            String html = "<select class='gwt-ListBox' multiple='multiple' size='2'>"
                    + "<option value='A'>A</option>"
                    + "<option value='B'>B</option>"
                    + "<option value='C'>C</option>" + "</select>";
            assertEquals(html, selectElmt);

            assertEquals("SELECT X.ID\nFROM PERSON X\nWHERE (X.CATEGORY IN (?, ?))", s.getSQL(args()));


            // change to sex
            ExpressionColumn left2 = (ExpressionColumn) comp.getLeft();
            left2.updateColumn("X", sess.getDatabase().getMainSchema()
                    .findTableOrView("PERSON").getColumn("category2"));
            cb.fireDirty();
        }

        {
            Comparison comp = (Comparison) s.getCondition();
            Parameter right = (Parameter) comp.getRight();
            Element selectElmt = right.getElement();

            String html = "<select class='gwt-ListBox' multiple='multiple' size='2'>"
                    + "<option value='X'>X</option>"
                    + "<option value='Y'>Y</option>"
                    + "<option value='Z'>Z</option>" + "</select>";
            assertEquals(html, selectElmt);

            assertEquals("SELECT X.ID\nFROM PERSON X\nWHERE (X.category2 IN ?)", s.getSQL(args()));

            // change to sex
            ExpressionColumn left2 = (ExpressionColumn) comp.getLeft();
            left2.updateColumn("X", sess.getDatabase().getMainSchema()
                    .findTableOrView("PERSON").getColumn("sex"));
            cb.fireDirty();
        }

        {
            Comparison comp = (Comparison) s.getCondition();
            Parameter right = (Parameter) comp.getRight();

            Element selectElmt = right.getElement();

            String html = "<select class='gwt-ListBox'>"
                    + "<option value='Please select...'>Please select...</option>"
                    + "<option value='M'>M</option>"
                    + "<option value='F'>F</option>"
                    + "</select>";
            assertEquals(html, selectElmt);

            assertEquals("SELECT X.ID\nFROM PERSON X\nWHERE (X.sex = ?)", s.getSQL(args()));
        }

        // check options in ListBox please, male, female
    }
View Full Code Here

        String sql0 = "SELECT x.id FROM Log x"
                + " WHERE x.id = ?";
        CommandBuilder cb = new CommandBuilder(sess, sql0, args("A"));
        RootPanel.get().add(cb);
        Select s = cb.getSelect();

        cb.fireDirty();

        {
            Comparison comp = (Comparison) s.getCondition();

            // change to sex
            ExpressionColumn left2 = (ExpressionColumn) comp.getLeft();
            left2.updateColumn("X", sess.getDatabase().getMainSchema()
                    .findTableOrView("LOG").getColumn("date"));
View Full Code Here

        sess.getDatabase().getMainSchema()
        .findTableOrView("PERSON").getColumn("owner").setEditor(new Editor.SelectEditor());

        CommandBuilder cb = new CommandBuilder(sess, "SELECT x.id FROM Person x", null);
        RootPanel.get().add(cb);
        Select s = cb.getSelect();

        Comparison c = s.addFirstCondition();
        s.fireDirty();
        ExpressionColumn left2 = (ExpressionColumn) c.getLeft();
        left2.updateColumn("X", sess.getDatabase().getMainSchema()
                .findTableOrView("PERSON").getColumn("owner"));
        c.fireDirty();
View Full Code Here

        List<Object> args = new ArrayList<Object>();
        args.add("M");
        CommandBuilder cb = new CommandBuilder(sess, "SELECT x.id FROM Person x WHERE sex = ?", args);
        RootPanel.get().add(cb);
        Select s = cb.getSelect();

        Comparison c = (Comparison) s.getCondition();
        Parameter p = (Parameter) c.getRight();
        SelectEditorWidget sew = (SelectEditorWidget) p.getEditorWidget();
        assertEquals("M", sew.getValue());
    }
View Full Code Here

        List<Object> args = new ArrayList<Object>();
        args.add("M");
        CommandBuilder cb = new CommandBuilder(sess, "SELECT x.id FROM Person x WHERE sex = ?", args);
        RootPanel.get().add(cb);
        Select s = cb.getSelect();

        // only now give them the enumeration
        Collection<Suggestion> s2 = new ArrayList();
        s2.add(new MultiWordSuggestion("M", "M"));
        s2.add(new MultiWordSuggestion("F", "F"));

        config.getEnumerateCallback().onSuccess(new Response(s2));

        Comparison c = (Comparison) s.getCondition();
        Parameter p = (Parameter) c.getRight();
        SelectEditorWidget sew = (SelectEditorWidget) p.getEditorWidget();
        assertEquals("M", sew.getValue());
    }
View Full Code Here

        List<Object> args = new ArrayList<Object>();
        args.add("13");
        args.add("15");
        CommandBuilder cb = new CommandBuilder(sess, sql0, args);
        RootPanel.get().add(cb);
        Select s = cb.getSelect();

       // cb.fireDirty();

        ConditionAndOr andOr = (ConditionAndOr) s.getCondition();
        Comparison comp = (Comparison) andOr.getLeft();
        Parameter right = (Parameter) comp.getRight();
        Element selectElmt = right.getElement();

        String html = "<input type='text' class='gwt-TextBox' value='13'>";
View Full Code Here

        if (readIf("(")) {
           Query command = parseSelectUnion();
            read(")");
            return command;
        }
       Select select = parseSelectSimple();
       return select;
    }
View Full Code Here

            top = join;
        }
    }

    private void parseSelectSimpleSelectPart(Select command) throws SQLException {
        Select temp = currentSelect;
        // make sure aggregate functions will not work in TOP and LIMIT
        currentSelect = null;
        if (readIf("TOP")) {
            // can't read more complex expressions here because
            // SELECT TOP 1 +? A FROM TEST could mean
View Full Code Here

TOP

Related Classes of com.redspr.redquerybuilder.core.client.command.dml.Select

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.