Beispiel #1
0
        public void QuoteSqlObjectName_should_trim_a_quoted_object_name()
        {
            var objectName = "   [MyObject]  ";

            var result = SqlObjectParser.QuoteSqlObjectName(objectName);

            Assert.That(result, Is.EqualTo(objectName.Trim()));
        }
Beispiel #2
0
        public void QuoteSqlObjectName_without_trim_should_leave_start_and_end_whitespace_intact()
        {
            var objectName       = "    MyObject   ";
            var quotedObjectName = "[    MyObject   ]";

            var result = SqlObjectParser.QuoteSqlObjectName(objectName, ObjectNameOptions.None);

            Assert.That(result, Is.EqualTo(quotedObjectName));
        }
Beispiel #3
0
        public void QuoteSqlObjectName_should_quote_and_not_escape_opening_brackets_in_object_name()
        {
            var objectName       = "MyO[bject";
            var quotedObjectName = "[MyO[bject]";

            var result = SqlObjectParser.QuoteSqlObjectName(objectName);

            Assert.That(result, Is.EqualTo(quotedObjectName));
        }
Beispiel #4
0
        public void QuoteSqlObjectName_should_quote_and_trim_an_unquoted_object_name()
        {
            var objectName       = "    MyObject   ";
            var quotedObjectName = "[MyObject]";

            var result = SqlObjectParser.QuoteSqlObjectName(objectName);

            Assert.That(result, Is.EqualTo(quotedObjectName));
        }
Beispiel #5
0
 private string Preprocess(string query)
 {
     if (string.IsNullOrEmpty(Schema))
     {
         query = new StripSchemaPreprocessor().Process(query);
     }
     if (!string.IsNullOrEmpty(Schema) && !variables.ContainsKey("schema"))
     {
         variables.Add("schema", SqlObjectParser.QuoteSqlObjectName(Schema));
     }
     if (variablesEnabled())
     {
         query = new VariableSubstitutionPreprocessor(variables).Process(query);
     }
     query = additionalScriptPreprocessors.Aggregate(query, (current, additionalScriptPreprocessor) => additionalScriptPreprocessor.Process(current));
     return(query);
 }
Beispiel #6
0
        public void QuoteSqlObjectName_should_fail_on_null_object_name()
        {
            string objectName = null;

            Assert.That(() => SqlObjectParser.QuoteSqlObjectName(objectName), Throws.Exception.TypeOf <ArgumentNullException>());
        }
Beispiel #7
0
        public void QuoteSqlObjectName_should_fail_on_large_object_name()
        {
            var objectName = new string('x', 129);

            Assert.That(() => SqlObjectParser.QuoteSqlObjectName(objectName), Throws.Exception.TypeOf <ArgumentOutOfRangeException>());
        }
Beispiel #8
0
 /// <summary>
 ///     Convert the <c>table</c> value into an appropriately-quoted identifier for the journal table's unique primary
 ///     key.
 /// </summary>
 /// <param name="table">Desired table name</param>
 /// <returns>Quoted journal table primary key identifier</returns>
 protected virtual string CreatePrimaryKeyName(string table)
 {
     return(SqlObjectParser.QuoteSqlObjectName("PK_" + table + "_Id"));
 }
Beispiel #9
0
 /// <summary>
 ///     Combine the <c>schema</c> and <c>table</c> values into an appropriately-quoted identifier for the journal
 ///     table.
 /// </summary>
 /// <param name="schema">Desired schema name supplied by configuration or <c>NULL</c></param>
 /// <param name="table">Desired table name</param>
 /// <returns>Quoted journal table identifier</returns>
 protected virtual string CreateTableName(string schema, string table)
 {
     return(string.IsNullOrEmpty(schema)
         ? SqlObjectParser.QuoteSqlObjectName(table)
         : SqlObjectParser.QuoteSqlObjectName(schema) + "." + SqlObjectParser.QuoteSqlObjectName(table));
 }