private static void testQueries(DBConnection cn, CustomModification[] mods)
        {
            // We don't test commands in Oracle because:
            // 1. There's no good junk value to pass in.
            // 2. The only way to keep the commands from actually modifying the database is with a transaction rollback, and we don't want to do that unless absolutely necessary.
            // And we don't test commands in MySQL because of reason 2 above.
            if (cn.DatabaseInfo is MySqlInfo || cn.DatabaseInfo is OracleInfo)
            {
                return;
            }

            foreach (var mod in mods)
            {
                foreach (var command in mod.commands)
                {
                    var cmd = DataAccessStatics.GetCommandFromRawQueryText(cn, command);
                    try {
                        cn.ExecuteReaderCommandWithSchemaOnlyBehavior(cmd, r => { });
                    }
                    catch (Exception e) {
                        throw new ApplicationException("Custom modification " + mod.name + " failed.", e);
                    }
                }
            }
        }
Exemple #2
0
        private static List <Column> validateQueryAndGetColumns(DBConnection cn, EnterpriseWebLibrary.Configuration.SystemDevelopment.Query query)
        {
            // Attempt to query with every postSelectFromClause to ensure validity.
            foreach (var postSelectFromClause in query.postSelectFromClauses)
            {
                cn.ExecuteReaderCommandWithSchemaOnlyBehavior(
                    DataAccessStatics.GetCommandFromRawQueryText(cn, query.selectFromClause + " " + postSelectFromClause.Value),
                    r => {});
            }

            return(Column.GetColumnsInQueryResults(cn, query.selectFromClause, false, false));
        }
Exemple #3
0
        private static List <Column> validateQueryAndGetColumns(DBConnection cn, Query query)
        {
            // Attempt to query with every postSelectFromClause to ensure validity.
            foreach (var postSelectFromClause in query.postSelectFromClauses)
            {
                try {
                    cn.ExecuteReaderCommandWithSchemaOnlyBehavior(DataAccessStatics.GetCommandFromRawQueryText(cn, query.selectFromClause + " " + postSelectFromClause.Value), r => { });
                }
                catch (Exception e) {
                    throw new UserCorrectableException($"Column retrieval failed for the {postSelectFromClause.name} postSelectFromClause.", e);
                }
            }

            return(Column.GetColumnsInQueryResults(cn, query.selectFromClause, false));
        }