Ejemplo n.º 1
0
        public void testGetTableColumn()
        {
            TGetTableColumn getTableColumn = new TGetTableColumn(EDbVendor.dbvoracle);

            getTableColumn.listStarColumn               = false;
            getTableColumn.showTreeStructure            = false;
            getTableColumn.showTableEffect              = true;
            getTableColumn.showColumnLocation           = true;
            getTableColumn.linkOrphanColumnToFirstTable = true;
            getTableColumn.isConsole = false;
            //getTableColumn.setMetaDatabase(new sampleMetaDB());

            String sqlText = "MERGE INTO bonuses D\r\n" +
                             "   USING(SELECT employee_id, salary, department_id FROM employees\r\n" +
                             "   WHERE department_id = 80) S\r\n" +
                             "   ON(D.employee_id = S.employee_id)\r\n" +
                             "   WHEN MATCHED THEN UPDATE SET D.bonus = D.bonus + S.salary * .01\r\n" +
                             "   WHEN NOT MATCHED THEN INSERT(D.employee_id, D.bonus)\r\n" +
                             "   VALUES(S.employee_id, S.salary * 0.1);";

            getTableColumn.runText(sqlText);
            String[] actualLines = getTableColumn.outList.ToString().Split(new string[] { "\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
            String   requiredStr = "Tables:\n"
                                   + "bonuses\n"
                                   + "employees\n"
                                   + "Fields:\n"
                                   + "bonuses.bonus\n"
                                   + "bonuses.employee_id\n"
                                   + "employees.department_id\n"
                                   + "employees.employee_id\n"
                                   + "employees.salary";

            String[] requiredLines = requiredStr.Split(new string[] { "\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
            compareTwoStringArray(requiredLines, actualLines, "Inline Query");
        }
Ejemplo n.º 2
0
        private void doGetTableColumn(EDbVendor dbvendor, String sqlText, String requiredStr)
        {
            TGetTableColumn getTableColumn = new TGetTableColumn(dbvendor);

            getTableColumn.listStarColumn               = false;
            getTableColumn.showTreeStructure            = false;
            getTableColumn.showTableEffect              = true;
            getTableColumn.showColumnLocation           = true;
            getTableColumn.linkOrphanColumnToFirstTable = true;
            getTableColumn.isConsole = false;
            //getTableColumn.setMetaDatabase(new sampleMetaDB());

            getTableColumn.runText(sqlText);
            String[] actualLines   = getTableColumn.outList.ToString().Split(new string[] { "\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
            String[] requiredLines = requiredStr.Split(new string[] { "\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
            compareTwoStringArray(requiredLines, actualLines, "Inline Query");
        }
Ejemplo n.º 3
0
        private void doTableColumnFiles(EDbVendor dbVendor, String dir, List <String> includeFiles)
        {
            if (!Directory.Exists(dir))
            {
                Console.WriteLine("Skip this testcase, directory not exists:" + dir);
                return;
            }

            TGetTableColumn getTableColumn = new TGetTableColumn(dbVendor);

            getTableColumn.listStarColumn               = false;
            getTableColumn.showTreeStructure            = false;
            getTableColumn.showTableEffect              = false;
            getTableColumn.showColumnLocation           = false;
            getTableColumn.linkOrphanColumnToFirstTable = true;
            getTableColumn.isConsole   = false;
            getTableColumn.showSummary = true;


            String[] allFiles = System.IO.Directory.GetFiles(dir, "*.sql", System.IO.SearchOption.AllDirectories);

            foreach (var file in allFiles)
            {
                FileInfo info = new FileInfo(file);
                if (!includeFile(info.Name, includeFiles))
                {
                    continue;
                }
                //sqlFile = new FileInfo(args[argList.IndexOf("/f") + 1]);
                getTableColumn.runText(File.ReadAllText(info.FullName));
                String outFile = Path.ChangeExtension(info.FullName, ".outn");
                if (!File.Exists(outFile))
                {
                    outFile = Path.ChangeExtension(info.FullName, ".out");
                }

                String[] requiredLines = File.ReadAllLines(outFile);
                String[] actualLines   = getTableColumn.outList.ToString().Split(new string[] { "\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
                compareTwoStringArray(requiredLines, actualLines, info.Name);
            }
        }