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§
Sourcefn integer_division_behavior(&self) -> DivisionBehavior
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)
Sourcefn supports_xor(&self) -> bool
fn supports_xor(&self) -> bool
Whether this mode supports the XOR operator
- MySQL: supports
^as XOR - SQLite: does not support XOR operator
Sourcefn supports_integer_div_operator(&self) -> bool
fn supports_integer_div_operator(&self) -> bool
Whether this mode supports the DIV operator (integer division)
- MySQL: supports
DIVfor integer division - SQLite: does not support
DIVkeyword
Sourcefn string_concat_operator(&self) -> ConcatOperator
fn string_concat_operator(&self) -> ConcatOperator
String concatenation operator preference
Returns how this mode handles string concatenation:
ConcatOperator::PipePipe: Uses||operatorConcatOperator::Function: UsesCONCAT()functionConcatOperator::Both: Supports both approaches