Module: ArelExtensions::Visitors::MSSQL
- Defined in:
- lib/arel_extensions/visitors/mssql.rb
Instance Method Summary collapse
- #visit_Arel_Nodes_NotRegexp(o, collector) ⇒ Object
-
#visit_Arel_Nodes_Regexp(o, collector) ⇒ Object
SQL Server does not know about REGEXP.
- #visit_ArelExtensions_Nodes_AiIMatches(o, collector) ⇒ Object
- #visit_ArelExtensions_Nodes_AiMatches(o, collector) ⇒ Object
- #visit_ArelExtensions_Nodes_Blank(o, collector) ⇒ Object
- #visit_ArelExtensions_Nodes_Cast(o, collector) ⇒ Object
-
#visit_ArelExtensions_Nodes_Ceil(o, collector) ⇒ Object
Math Functions.
- #visit_ArelExtensions_Nodes_Collate(o, collector) ⇒ Object
- #visit_ArelExtensions_Nodes_Concat(o, collector) ⇒ Object
- #visit_ArelExtensions_Nodes_DateAdd(o, collector) ⇒ Object
- #visit_ArelExtensions_Nodes_DateDiff(o, collector) ⇒ Object
- #visit_ArelExtensions_Nodes_Duration(o, collector) ⇒ Object
- #visit_ArelExtensions_Nodes_FindInSet(o, collector) ⇒ Object
- #visit_ArelExtensions_Nodes_Format(o, collector) ⇒ Object
- #visit_ArelExtensions_Nodes_FormattedNumber(o, collector) ⇒ Object
-
#visit_ArelExtensions_Nodes_GroupConcat(o, collector) ⇒ Object
TODO;.
-
#visit_ArelExtensions_Nodes_IDoesNotMatch(o, collector) ⇒ Object
TODO; manage case insensitivity.
-
#visit_ArelExtensions_Nodes_IMatches(o, collector) ⇒ Object
TODO; manage case insensitivity.
- #visit_ArelExtensions_Nodes_IsNotNull(o, collector) ⇒ Object
- #visit_ArelExtensions_Nodes_IsNull(o, collector) ⇒ Object
- #visit_ArelExtensions_Nodes_JsonGet(o, collector) ⇒ Object
- #visit_ArelExtensions_Nodes_Length(o, collector) ⇒ Object
- #visit_ArelExtensions_Nodes_LevenshteinDistance(o, collector) ⇒ Object
- #visit_ArelExtensions_Nodes_Locate(o, collector) ⇒ Object
- #visit_ArelExtensions_Nodes_Log10(o, collector) ⇒ Object
- #visit_ArelExtensions_Nodes_Ltrim(o, collector) ⇒ Object
- #visit_ArelExtensions_Nodes_MD5(o, collector) ⇒ Object
- #visit_ArelExtensions_Nodes_NotBlank(o, collector) ⇒ Object
- #visit_ArelExtensions_Nodes_Power(o, collector) ⇒ Object
- #visit_ArelExtensions_Nodes_Repeat(o, collector) ⇒ Object
- #visit_ArelExtensions_Nodes_Replace(o, collector) ⇒ Object
- #visit_ArelExtensions_Nodes_Round(o, collector) ⇒ Object
- #visit_ArelExtensions_Nodes_Rtrim(o, collector) ⇒ Object
- #visit_ArelExtensions_Nodes_SMatches(o, collector) ⇒ Object
- #visit_ArelExtensions_Nodes_Std(o, collector) ⇒ Object
- #visit_ArelExtensions_Nodes_Substring(o, collector) ⇒ Object
- #visit_ArelExtensions_Nodes_Trim(o, collector) ⇒ Object
- #visit_ArelExtensions_Nodes_Variance(o, collector) ⇒ Object
Instance Method Details
#visit_Arel_Nodes_NotRegexp(o, collector) ⇒ Object
392 393 394 395 396 |
# File 'lib/arel_extensions/visitors/mssql.rb', line 392 def visit_Arel_Nodes_NotRegexp o, collector collector = visit o.left, collector collector << "NOT LIKE '%#{o.right}%'" collector end |
#visit_Arel_Nodes_Regexp(o, collector) ⇒ Object
SQL Server does not know about REGEXP
386 387 388 389 390 |
# File 'lib/arel_extensions/visitors/mssql.rb', line 386 def visit_Arel_Nodes_Regexp o, collector collector = visit o.left, collector collector << "LIKE '%#{o.right}%'" collector end |
#visit_ArelExtensions_Nodes_AiIMatches(o, collector) ⇒ Object
344 345 346 347 348 349 350 351 352 353 354 |
# File 'lib/arel_extensions/visitors/mssql.rb', line 344 def visit_ArelExtensions_Nodes_AiIMatches o, collector collector = visit o.left.collate(true,true), collector collector << ' LIKE ' collector = visit o.right.collate(true,true), collector if o.escape collector << ' ESCAPE ' visit o.escape, collector else collector end end |
#visit_ArelExtensions_Nodes_AiMatches(o, collector) ⇒ Object
332 333 334 335 336 337 338 339 340 341 342 |
# File 'lib/arel_extensions/visitors/mssql.rb', line 332 def visit_ArelExtensions_Nodes_AiMatches o, collector collector = visit o.left.ai_collate, collector collector << ' LIKE ' collector = visit o.right.ai_collate, collector if o.escape collector << ' ESCAPE ' visit o.escape, collector else collector end end |
#visit_ArelExtensions_Nodes_Blank(o, collector) ⇒ Object
236 237 238 |
# File 'lib/arel_extensions/visitors/mssql.rb', line 236 def visit_ArelExtensions_Nodes_Blank o, collector visit o.expr.coalesce('').trim.length.eq(0), collector end |
#visit_ArelExtensions_Nodes_Cast(o, collector) ⇒ Object
428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 |
# File 'lib/arel_extensions/visitors/mssql.rb', line 428 def visit_ArelExtensions_Nodes_Cast o, collector case o.as_attr when :string as_attr = Arel::Nodes::SqlLiteral.new('varchar') when :time as_attr = Arel::Nodes::SqlLiteral.new('time') when :date as_attr = Arel::Nodes::SqlLiteral.new('date') when :datetime as_attr = Arel::Nodes::SqlLiteral.new('datetime') when :number,:decimal, :float as_attr = Arel::Nodes::SqlLiteral.new('decimal(10,6)') when :int collector << "CAST(CAST(" collector = visit o.left, collector collector << " AS decimal(10,0)) AS int)" return collector when :binary as_attr = Arel::Nodes::SqlLiteral.new('binary') else as_attr = Arel::Nodes::SqlLiteral.new(o.as_attr.to_s) end collector << "CAST(" collector = visit o.left, collector collector << " AS " collector = visit as_attr, collector collector << ")" collector end |
#visit_ArelExtensions_Nodes_Ceil(o, collector) ⇒ Object
Math Functions
25 26 27 28 29 30 |
# File 'lib/arel_extensions/visitors/mssql.rb', line 25 def visit_ArelExtensions_Nodes_Ceil o, collector collector << "CEILING(" collector = visit o.expr, collector collector << ")" collector end |
#visit_ArelExtensions_Nodes_Collate(o, collector) ⇒ Object
368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 |
# File 'lib/arel_extensions/visitors/mssql.rb', line 368 def visit_ArelExtensions_Nodes_Collate o, collector if o.ai && o.ci collector = visit o.expressions.first, collector collector << ' COLLATE Latin1_General_CI_AI' elsif o.ai collector = visit o.expressions.first, collector collector << ' COLLATE Latin1_General_CS_AI' elsif o.ci collector = visit o.expressions.first, collector collector << ' COLLATE Latin1_General_CI_AS' else collector = visit o.expressions.first, collector collector << ' COLLATE Latin1_General_CS_AS' end collector end |
#visit_ArelExtensions_Nodes_Concat(o, collector) ⇒ Object
66 67 68 69 70 71 72 73 74 |
# File 'lib/arel_extensions/visitors/mssql.rb', line 66 def visit_ArelExtensions_Nodes_Concat o, collector collector << "CONCAT(" o.expressions.each_with_index { |arg, i| collector << Arel::Visitors::MSSQL::COMMA unless i == 0 collector = visit arg, collector } collector << ")" collector end |
#visit_ArelExtensions_Nodes_DateAdd(o, collector) ⇒ Object
116 117 118 119 120 121 122 123 124 125 |
# File 'lib/arel_extensions/visitors/mssql.rb', line 116 def visit_ArelExtensions_Nodes_DateAdd o, collector collector << "DATEADD(" collector = visit o.mssql_datepart(o.right), collector collector << Arel::Visitors::MSSQL::COMMA collector = visit o.mssql_value(o.right), collector collector << Arel::Visitors::MSSQL::COMMA collector = visit o.left, collector collector << ")" collector end |
#visit_ArelExtensions_Nodes_DateDiff(o, collector) ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/arel_extensions/visitors/mssql.rb', line 88 def visit_ArelExtensions_Nodes_DateDiff o, collector if o.right_node_type == :ruby_date || o.right_node_type == :ruby_time || o.right_node_type == :date || o.right_node_type == :datetime || o.right_node_type == :time collector << if o.left_node_type == :ruby_time || o.left_node_type == :datetime || o.left_node_type == :time 'DATEDIFF(second' else 'DATEDIFF(day' end collector << Arel::Visitors::MSSQL::COMMA collector = visit o.right, collector collector << Arel::Visitors::MSSQL::COMMA collector = visit o.left, collector collector << ')' else da = ArelExtensions::Nodes::DateAdd.new([]) collector << "DATEADD(" collector = visit da.mssql_datepart(o.right), collector collector << Arel::Visitors::MSSQL::COMMA collector << "-(" collector = visit da.mssql_value(o.right), collector collector << ")" collector << Arel::Visitors::MSSQL::COMMA collector = visit o.left, collector collector << ")" collector end collector end |
#visit_ArelExtensions_Nodes_Duration(o, collector) ⇒ Object
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/arel_extensions/visitors/mssql.rb', line 127 def visit_ArelExtensions_Nodes_Duration o, collector if o.with_interval && o.left.end_with?('i') collector = visit o.right, collector else left = o.left.end_with?('i') ? o.left[0..-2] : o.left conv = ['h', 'mn', 's'].include?(o.left) collector << 'DATEPART(' collector << Arel::Visitors::MSSQL::DATE_MAPPING[left] collector << Arel::Visitors::MSSQL::COMMA collector << 'CONVERT(datetime,' if conv collector = visit o.right, collector collector << ')' if conv collector << ")" end collector end |
#visit_ArelExtensions_Nodes_FindInSet(o, collector) ⇒ Object
296 297 298 299 300 301 302 303 304 |
# File 'lib/arel_extensions/visitors/mssql.rb', line 296 def visit_ArelExtensions_Nodes_FindInSet o, collector collector << "dbo.FIND_IN_SET(" o.expressions.each_with_index { |arg, i| collector << Arel::Visitors::MSSQL::COMMA unless i == 0 collector = visit arg, collector } collector << ")" collector end |
#visit_ArelExtensions_Nodes_Format(o, collector) ⇒ Object
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 |
# File 'lib/arel_extensions/visitors/mssql.rb', line 244 def visit_ArelExtensions_Nodes_Format o, collector f = o.iso_format.dup Arel::Visitors::MSSQL::DATE_FORMAT_DIRECTIVES.each { |d, r| f.gsub!(d, r) } if Arel::Visitors::MSSQL::DATE_CONVERT_FORMATS[f] collector << "CONVERT(VARCHAR(#{f.length})" collector << Arel::Visitors::MSSQL::COMMA collector = visit o.left, collector collector << Arel::Visitors::MSSQL::COMMA collector << Arel::Visitors::MSSQL::DATE_CONVERT_FORMATS[f].to_s collector << ')' collector else collector << "(" t = o.iso_format.split('%') t.each_with_index {|str, i| if i == 0 && t[0] != '%' collector = visit Arel::Nodes.build_quoted(str), collector if str.length > 1 collector << Arel::Visitors::MSSQL::COMMA collector = visit Arel::Nodes.build_quoted(str.sub(/\A./, '')), collector end elsif str.length > 0 if !Arel::Visitors::MSSQL::DATE_FORMAT_DIRECTIVES['%' + str[0]].blank? collector << 'LTRIM(STR(DATEPART(' collector << Arel::Visitors::MSSQL::DATE_FORMAT_DIRECTIVES['%' + str[0]] collector << Arel::Visitors::MSSQL::COMMA collector = visit o.left, collector collector << ')))' if str.length > 1 collector << ' + ' collector = visit Arel::Nodes.build_quoted(str.sub(/\A./, '')), collector end end end collector << ' + ' if t[i + 1] } collector << ')' collector end end |
#visit_ArelExtensions_Nodes_FormattedNumber(o, collector) ⇒ Object
458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 |
# File 'lib/arel_extensions/visitors/mssql.rb', line 458 def visit_ArelExtensions_Nodes_FormattedNumber o, collector col = o.left.coalesce(0) locale = Arel::Nodes.build_quoted(o.locale.tr('_','-')) param = Arel::Nodes.build_quoted("N#{o.precision}") sign = ArelExtensions::Nodes::Case.new.when(col<0). then('-'). else(o.flags.include?('+') ? '+' : (o.flags.include?(' ') ? ' ' : '')) sign_length = o.flags.include?('+') || o.flags.include?(' ') ? Arel::Nodes.build_quoted(1) : ArelExtensions::Nodes::Case.new.when(col<0).then(1).else(0) if o.scientific_notation number = ArelExtensions::Nodes::Concat.new([ Arel::Nodes::NamedFunction.new('FORMAT',[ col.abs/Arel::Nodes.build_quoted(10).pow(col.abs.log10.floor), param, locale ]), o.type, Arel::Nodes::NamedFunction.new('FORMAT',[ col.abs.log10.floor, Arel::Nodes.build_quoted('N0'), locale ]) ]) else number = Arel::Nodes::NamedFunction.new('FORMAT',[ Arel::Nodes.build_quoted(col.abs), param, locale ]) end repeated_char = (o.width == 0) ? Arel::Nodes.build_quoted('') : ArelExtensions::Nodes::Case.new(). when(Arel::Nodes.build_quoted(o.width).abs-(number.length+sign_length)>0). then(Arel::Nodes.build_quoted( o.flags.include?('-') ? ' ' : (o.flags.include?('0') ? '0' : ' ') ).repeat(Arel::Nodes.build_quoted(o.width).abs-(number.length+sign_length)) ). else('') before = (!o.flags.include?('0'))&&(!o.flags.include?('-')) ? repeated_char : '' middle = (o.flags.include?('0'))&&(!o.flags.include?('-')) ? repeated_char : '' after = o.flags.include?('-') ? repeated_char : '' full_number = ArelExtensions::Nodes::Concat.new([ before, sign, middle, number, after ]) collector = visit ArelExtensions::Nodes::Concat.new([Arel::Nodes.build_quoted(o.prefix),full_number,Arel::Nodes.build_quoted(o.suffix)]), collector collector end |
#visit_ArelExtensions_Nodes_GroupConcat(o, collector) ⇒ Object
TODO;
399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 |
# File 'lib/arel_extensions/visitors/mssql.rb', line 399 def visit_ArelExtensions_Nodes_GroupConcat o, collector collector << "(STRING_AGG(" collector = visit o.left, collector collector << Arel::Visitors::Oracle::COMMA if o.separator && o.selector != 'NULL' collector = visit o.separator, collector else collector = visit Arel::Nodes.build_quoted(','), collector end collector << ") WITHIN GROUP (ORDER BY " if !o.order.blank? o.order.each_with_index do |order,i| collector << Arel::Visitors::Oracle::COMMA unless i == 0 collector = visit order, collector end else collector = visit o.left, collector end collector << "))" collector end |
#visit_ArelExtensions_Nodes_IDoesNotMatch(o, collector) ⇒ Object
TODO; manage case insensitivity
320 321 322 323 324 325 326 327 328 329 330 |
# File 'lib/arel_extensions/visitors/mssql.rb', line 320 def visit_ArelExtensions_Nodes_IDoesNotMatch o, collector collector = visit o.left.ci_collate, collector collector << ' NOT LIKE ' collector = visit o.right.ci_collate, collector if o.escape collector << ' ESCAPE ' visit o.escape, collector else collector end end |
#visit_ArelExtensions_Nodes_IMatches(o, collector) ⇒ Object
TODO; manage case insensitivity
307 308 309 310 311 312 313 314 315 316 317 |
# File 'lib/arel_extensions/visitors/mssql.rb', line 307 def visit_ArelExtensions_Nodes_IMatches o, collector collector = visit o.left.ci_collate, collector collector << ' LIKE ' collector = visit o.right.ci_collate, collector if o.escape collector << ' ESCAPE ' visit o.escape, collector else collector end end |
#visit_ArelExtensions_Nodes_IsNotNull(o, collector) ⇒ Object
59 60 61 62 63 64 |
# File 'lib/arel_extensions/visitors/mssql.rb', line 59 def visit_ArelExtensions_Nodes_IsNotNull o, collector collector << "(" collector = visit o.expr, collector collector << " IS NOT NULL)" collector end |
#visit_ArelExtensions_Nodes_IsNull(o, collector) ⇒ Object
52 53 54 55 56 57 |
# File 'lib/arel_extensions/visitors/mssql.rb', line 52 def visit_ArelExtensions_Nodes_IsNull o, collector collector << "(" collector = visit o.expr, collector collector << " IS NULL)" collector end |
#visit_ArelExtensions_Nodes_JsonGet(o, collector) ⇒ Object
538 539 540 541 542 543 544 545 546 547 548 549 |
# File 'lib/arel_extensions/visitors/mssql.rb', line 538 def visit_ArelExtensions_Nodes_JsonGet o,collector collector << 'JSON_VALUE(' collector = visit o.dict, collector collector << Arel::Visitors::MySQL::COMMA if o.key.is_a?(Integer) collector << "\"$[#{o.key}]\"" else collector = visit Arel::Nodes.build_quoted('$.')+o.key, collector end collector << ')' collector end |
#visit_ArelExtensions_Nodes_Length(o, collector) ⇒ Object
144 145 146 147 148 149 |
# File 'lib/arel_extensions/visitors/mssql.rb', line 144 def visit_ArelExtensions_Nodes_Length o, collector collector << "LEN(" collector = visit o.expr, collector collector << ")" collector end |
#visit_ArelExtensions_Nodes_LevenshteinDistance(o, collector) ⇒ Object
528 529 530 531 532 533 534 535 |
# File 'lib/arel_extensions/visitors/mssql.rb', line 528 def visit_ArelExtensions_Nodes_LevenshteinDistance o, collector collector << "dbo.LEVENSHTEIN_DISTANCE(" collector = visit o.left, collector collector << Arel::Visitors::ToSql::COMMA collector = visit o.right, collector collector << ')' collector end |
#visit_ArelExtensions_Nodes_Locate(o, collector) ⇒ Object
165 166 167 168 169 170 171 172 |
# File 'lib/arel_extensions/visitors/mssql.rb', line 165 def visit_ArelExtensions_Nodes_Locate o, collector collector << "CHARINDEX(" collector = visit o.right, collector collector << Arel::Visitors::MSSQL::COMMA collector = visit o.left, collector collector << ")" collector end |
#visit_ArelExtensions_Nodes_Log10(o, collector) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/arel_extensions/visitors/mssql.rb', line 32 def visit_ArelExtensions_Nodes_Log10 o, collector collector << "LOG10(" o.expressions.each_with_index { |arg, i| collector << Arel::Visitors::ToSql::COMMA unless i == 0 collector = visit arg, collector } collector << ")" collector end |
#visit_ArelExtensions_Nodes_Ltrim(o, collector) ⇒ Object
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
# File 'lib/arel_extensions/visitors/mssql.rb', line 202 def visit_ArelExtensions_Nodes_Ltrim o, collector if o.right collector << "REPLACE(REPLACE(LTRIM(REPLACE(REPLACE(" collector = visit o.left, collector collector << ", ' ', '~'), " collector = visit o.right, collector collector << ", ' ')), ' ', " collector = visit o.right, collector collector << "), '~', ' ')" else collector << "LTRIM(" collector = visit o.left, collector collector << ")" end collector end |
#visit_ArelExtensions_Nodes_MD5(o, collector) ⇒ Object
421 422 423 424 425 426 |
# File 'lib/arel_extensions/visitors/mssql.rb', line 421 def visit_ArelExtensions_Nodes_MD5 o, collector collector << "LOWER(CONVERT(NVARCHAR(32),HashBytes('MD5',CONVERT(VARCHAR," collector = visit o.left, collector collector << ")),2))" collector end |
#visit_ArelExtensions_Nodes_NotBlank(o, collector) ⇒ Object
240 241 242 |
# File 'lib/arel_extensions/visitors/mssql.rb', line 240 def visit_ArelExtensions_Nodes_NotBlank o, collector visit o.expr.coalesce('').trim.length.gt(0), collector end |
#visit_ArelExtensions_Nodes_Power(o, collector) ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/arel_extensions/visitors/mssql.rb', line 42 def visit_ArelExtensions_Nodes_Power o, collector collector << "POWER(" o.expressions.each_with_index { |arg, i| collector << Arel::Visitors::ToSql::COMMA unless i == 0 collector = visit arg, collector } collector << ")" collector end |
#visit_ArelExtensions_Nodes_Repeat(o, collector) ⇒ Object
76 77 78 79 80 81 82 83 84 |
# File 'lib/arel_extensions/visitors/mssql.rb', line 76 def visit_ArelExtensions_Nodes_Repeat o, collector collector << "REPLICATE(" o.expressions.each_with_index { |arg, i| collector << Arel::Visitors::ToSql::COMMA unless i == 0 collector = visit arg, collector } collector << ")" collector end |
#visit_ArelExtensions_Nodes_Replace(o, collector) ⇒ Object
286 287 288 289 290 291 292 293 294 |
# File 'lib/arel_extensions/visitors/mssql.rb', line 286 def visit_ArelExtensions_Nodes_Replace o, collector collector << "REPLACE(" o.expressions.each_with_index { |arg, i| collector << Arel::Visitors::MSSQL::COMMA unless i == 0 collector = visit arg, collector } collector << ")" collector end |
#visit_ArelExtensions_Nodes_Round(o, collector) ⇒ Object
151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/arel_extensions/visitors/mssql.rb', line 151 def visit_ArelExtensions_Nodes_Round o, collector collector << "ROUND(" o.expressions.each_with_index { |arg, i| collector << Arel::Visitors::MSSQL::COMMA unless i == 0 collector = visit arg, collector } if o.expressions.length == 1 collector << Arel::Visitors::MSSQL::COMMA collector << "0" end collector << ")" collector end |
#visit_ArelExtensions_Nodes_Rtrim(o, collector) ⇒ Object
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
# File 'lib/arel_extensions/visitors/mssql.rb', line 219 def visit_ArelExtensions_Nodes_Rtrim o, collector if o.right collector << "REPLACE(REPLACE(RTRIM(REPLACE(REPLACE(" collector = visit o.left, collector collector << ", ' ', '~'), " collector = visit o.right, collector collector << ", ' ')), ' ', " collector = visit o.right, collector collector << "), '~', ' ')" else collector << "RTRIM(" collector = visit o.left, collector collector << ")" end collector end |
#visit_ArelExtensions_Nodes_SMatches(o, collector) ⇒ Object
356 357 358 359 360 361 362 363 364 365 366 |
# File 'lib/arel_extensions/visitors/mssql.rb', line 356 def visit_ArelExtensions_Nodes_SMatches o, collector collector = visit o.left.collate, collector collector << ' LIKE ' collector = visit o.right.collate, collector if o.escape collector << ' ESCAPE ' visit o.escape, collector else collector end end |
#visit_ArelExtensions_Nodes_Std(o, collector) ⇒ Object
513 514 515 516 517 518 |
# File 'lib/arel_extensions/visitors/mssql.rb', line 513 def visit_ArelExtensions_Nodes_Std o, collector collector << (o.unbiased_estimator ? "STDEV(" : "STDEVP(") visit o.left, collector collector << ")" collector end |
#visit_ArelExtensions_Nodes_Substring(o, collector) ⇒ Object
174 175 176 177 178 179 180 181 182 183 |
# File 'lib/arel_extensions/visitors/mssql.rb', line 174 def visit_ArelExtensions_Nodes_Substring o, collector collector << 'SUBSTRING(' collector = visit o.expressions[0], collector collector << Arel::Visitors::MSSQL::COMMA collector = visit o.expressions[1], collector collector << Arel::Visitors::MSSQL::COMMA collector = o.expressions[2] ? visit(o.expressions[2], collector) : visit(o.expressions[0].length, collector) collector << ')' collector end |
#visit_ArelExtensions_Nodes_Trim(o, collector) ⇒ Object
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
# File 'lib/arel_extensions/visitors/mssql.rb', line 185 def visit_ArelExtensions_Nodes_Trim o, collector if o.right collector << "REPLACE(REPLACE(LTRIM(RTRIM(REPLACE(REPLACE(" collector = visit o.left, collector collector << ", ' ', '~'), " collector = visit o.right, collector collector << ", ' '))), ' ', " collector = visit o.right, collector collector << "), '~', ' ')" else collector << "LTRIM(RTRIM(" collector = visit o.left, collector collector << "))" end collector end |
#visit_ArelExtensions_Nodes_Variance(o, collector) ⇒ Object
520 521 522 523 524 525 |
# File 'lib/arel_extensions/visitors/mssql.rb', line 520 def visit_ArelExtensions_Nodes_Variance o, collector collector << (o.unbiased_estimator ? "VAR(" : "VARP(") visit o.left, collector collector << ")" collector end |