Пример #1
0
        public void testValues2()
        {
            TGSqlParser sqlparser = new TGSqlParser(EDbVendor.dbvgreenplum);

            sqlparser.sqltext = "SELECT f.* FROM films f, (VALUES('MGM', 'Horror'), ('UA', \n" + "'Sci-Fi')) AS t (studio, kind) WHERE f.studio = t.studio AND \n" + "f.kind = t.kind;";
            Assert.IsTrue(sqlparser.parse() == 0);
            TSelectSqlStatement select = (TSelectSqlStatement)sqlparser.sqlstatements.get(0);

            Assert.IsTrue(select.joins.size() == 2);
            TTable table2 = select.joins.getJoin(1).Table;

            Assert.IsTrue(table2.TableType == ETableSource.subquery);
            Assert.IsTrue(table2.AliasClause.AliasName.ToString().Equals("t", StringComparison.CurrentCultureIgnoreCase));
            Assert.IsTrue(table2.AliasClause.Columns.getObjectName(0).ToString().Equals("studio", StringComparison.CurrentCultureIgnoreCase));
            select = table2.Subquery;

            TValueClause valueClause = select.ValueClause;

            Assert.IsTrue(valueClause.ValueRows.size() == 2);
            TValueRowItem rowItem = valueClause.ValueRows.getValueRowItem(0);

            Assert.IsTrue(rowItem.ExprList.getExpression(0).ToString().Equals("'MGM'", StringComparison.CurrentCultureIgnoreCase));
            Assert.IsTrue(rowItem.ExprList.getExpression(1).ToString().Equals("'Horror'", StringComparison.CurrentCultureIgnoreCase));
            rowItem = valueClause.ValueRows.getValueRowItem(1);
            Assert.IsTrue(rowItem.ExprList.getExpression(0).ToString().Equals("'UA'", StringComparison.CurrentCultureIgnoreCase));
            Assert.IsTrue(rowItem.ExprList.getExpression(1).ToString().Equals("'Sci-Fi'", StringComparison.CurrentCultureIgnoreCase));
        }
Пример #2
0
        public void testValues1()
        {
            TGSqlParser sqlparser = new TGSqlParser(EDbVendor.dbvgreenplum);

            sqlparser.sqltext = "VALUES (1, 'one'), (2, 'two'), (3, 'three');";
            Assert.IsTrue(sqlparser.parse() == 0);
            TSelectSqlStatement select      = (TSelectSqlStatement)sqlparser.sqlstatements.get(0);
            TValueClause        valueClause = select.ValueClause;

            Assert.IsTrue(valueClause.ValueRows.size() == 3);
            TValueRowItem rowItem = valueClause.ValueRows.getValueRowItem(0);

            Assert.IsTrue(rowItem.ExprList.getExpression(0).ToString().Equals("1", StringComparison.CurrentCultureIgnoreCase));
            Assert.IsTrue(rowItem.ExprList.getExpression(1).ToString().Equals("'one'", StringComparison.CurrentCultureIgnoreCase));
        }