OperatorBehavior

Trait OperatorBehavior 

Source
pub trait OperatorBehavior {
    // Required methods
    fn integer_division_behavior(&self) -> DivisionBehavior;
    fn supports_xor(&self) -> bool;
    fn supports_integer_div_operator(&self) -> bool;
    fn string_concat_operator(&self) -> ConcatOperator;
}
Expand description

Trait for mode-specific operator behaviors

This trait defines how various operators behave in different SQL modes. Each SQL mode (MySQL, SQLite) implements this trait to specify its operator semantics.

§Example

use vibesql_types::{DivisionBehavior, MySqlModeFlags, OperatorBehavior, SqlMode};

let mode = SqlMode::MySQL { flags: MySqlModeFlags::default() };
assert_eq!(mode.integer_division_behavior(), DivisionBehavior::Decimal);
assert!(mode.supports_xor());

Required Methods§

Source

fn integer_division_behavior(&self) -> DivisionBehavior

Division behavior for integer/integer operands

Returns whether division of two integers should return:

  • DivisionBehavior::Integer: Truncated integer result (SQLite)
  • DivisionBehavior::Decimal: Floating-point result (MySQL)
Source

fn supports_xor(&self) -> bool

Whether this mode supports the XOR operator

  • MySQL: supports ^ as XOR
  • SQLite: does not support XOR operator
Source

fn supports_integer_div_operator(&self) -> bool

Whether this mode supports the DIV operator (integer division)

  • MySQL: supports DIV for integer division
  • SQLite: does not support DIV keyword
Source

fn string_concat_operator(&self) -> ConcatOperator

String concatenation operator preference

Returns how this mode handles string concatenation:

  • ConcatOperator::PipePipe: Uses || operator
  • ConcatOperator::Function: Uses CONCAT() function
  • ConcatOperator::Both: Supports both approaches

Implementors§