1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
// Copyright Materialize, Inc. and contributors. All rights reserved.
//
// Use of this software is governed by the Business Source License
// included in the LICENSE file.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0.
use repr::strconv;
sqlfunc!(
#[sqlname = "!"]
#[preserves_uniqueness = true]
fn not(a: bool) -> bool {
!a
}
);
sqlfunc!(
#[sqlname = "booltostr"]
#[preserves_uniqueness = true]
fn cast_bool_to_string<'a>(a: bool) -> &'a str {
match a {
true => "true",
false => "false",
}
}
);
sqlfunc!(
#[sqlname = "booltostrns"]
#[preserves_uniqueness = true]
fn cast_bool_to_string_nonstandard<'a>(a: bool) -> &'a str {
// N.B. this function differs from `cast_bool_to_string_implicit` because
// the SQL specification requires `true` and `false` to be spelled out in
// explicit casts, while PostgreSQL prefers its more concise `t` and `f`
// representation in some contexts, for historical reasons.
strconv::format_bool_static(a)
}
);
sqlfunc!(
#[sqlname = "booltoi32"]
#[preserves_uniqueness = true]
fn cast_bool_to_int32(a: bool) -> i32 {
match a {
true => 1,
false => 0,
}
}
);