//! SQL translations for interval and timestamp arithmetic operators

use hamelin_lib::func::defs::{
    CalendarIntervalDivideInt, CalendarIntervalMinusCalendarInterval, CalendarIntervalMultiplyInt,
    CalendarIntervalPlusCalendarInterval, CalendarIntervalPlusTimestamp,
    IntMultiplyCalendarInterval, IntervalDivideNumeric, IntervalMinusInterval,
    IntervalMultiplyNumeric, IntervalPlusInterval, IntervalPlusTimestamp, NumericMultiplyInterval,
    TimestampMinusCalendarInterval, TimestampMinusInterval, TimestampMinusTimestamp,
    TimestampPlusCalendarInterval, TimestampPlusInterval,
};

use crate::utils::direct_binary_operator_translation;
use crate::TranslationRegistry;

/// Register interval/timestamp arithmetic translations.
pub fn register(registry: &mut TranslationRegistry) {
    // Interval * Numeric, Numeric * Interval, Interval / Numeric
    registry.register::<IntervalMultiplyNumeric>(direct_binary_operator_translation);
    registry.register::<NumericMultiplyInterval>(direct_binary_operator_translation);
    registry.register::<IntervalDivideNumeric>(direct_binary_operator_translation);

    // CalendarInterval arithmetic
    registry.register::<CalendarIntervalPlusCalendarInterval>(direct_binary_operator_translation);
    registry.register::<CalendarIntervalMinusCalendarInterval>(direct_binary_operator_translation);
    registry.register::<CalendarIntervalMultiplyInt>(direct_binary_operator_translation);
    registry.register::<IntMultiplyCalendarInterval>(direct_binary_operator_translation);
    registry.register::<CalendarIntervalDivideInt>(direct_binary_operator_translation);

    // Timestamp arithmetic
    registry.register::<TimestampMinusInterval>(direct_binary_operator_translation);
    registry.register::<TimestampMinusCalendarInterval>(direct_binary_operator_translation);
    registry.register::<IntervalPlusTimestamp>(direct_binary_operator_translation);
    registry.register::<CalendarIntervalPlusTimestamp>(direct_binary_operator_translation);
    registry.register::<TimestampMinusTimestamp>(direct_binary_operator_translation);
    registry.register::<TimestampPlusInterval>(direct_binary_operator_translation);
    registry.register::<TimestampPlusCalendarInterval>(direct_binary_operator_translation);

    // Interval + Interval, Interval - Interval
    registry.register::<IntervalPlusInterval>(direct_binary_operator_translation);
    registry.register::<IntervalMinusInterval>(direct_binary_operator_translation);
}
