Documentation
¶
Overview ¶
Package sqldialect centralizes SQL-dialect literals shared by metadata query packages. Keeping one implementation prevents a corrected or newly added backend from silently leaving account-history queries inconsistent with stake queries. Every helper is pure and treats a nil db the same as sqlite.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ArithmeticParam ¶ added in v0.65.0
ArithmeticParam returns the bind fragment for a types.Uint64 operand used directly in arithmetic. MySQL and Postgres require an explicit numeric cast so a bound decimal string never promotes the expression to floating point.
func BoolLiteral ¶ added in v0.65.0
BoolLiteral renders a boolean literal for raw SQL.
func IntegerCastType ¶
IntegerCastType returns the backend-native integer type used to CAST the text-encoded (types.Uint64) columns before arithmetic or numeric comparison. The utxo.amount and account.reward columns used by the metadata stake and voting-power queries are stored as decimal-string TEXT (see types.Uint64.Value) regardless of backend, so any SUM, arithmetic, or ordering comparison touching them must cast first: sqlite is loosely typed and tolerates INTEGER; mysql needs UNSIGNED to preserve values above math.MaxInt64 exactly (a signed cast would overflow); postgres needs NUMERIC and, unlike sqlite/mysql, never implicitly coerces TEXT to a numeric type, so postgres queries fail outright without the cast.
func Name ¶
Name returns the lower-cased dialect name for db, or "" for a nil db (treated the same as sqlite by every helper below).
func TextCastType ¶ added in v0.65.0
TextCastType returns the CAST target for the decimal-string representation stored in types.Uint64 columns.
func TransactionTableName ¶
TransactionTableName returns the quoted reference to the "transaction" table for the backend dialect of db. mysql does not require quoting here (TRANSACTION is not a reserved word), but backtick-quoting it is always valid there; postgres and sqlite both require double quotes because "transaction" collides with the SQL TRANSACTION keyword in unquoted position.
Types ¶
This section is empty.