From 11e21e201cbf95d8a7b803492adfb70689a4460a Mon Sep 17 00:00:00 2001 From: Ryan Leckey Date: Mon, 15 Jun 2020 20:41:19 -0700 Subject: [PATCH] feat: add a name method to TypeInfo --- sqlx-core/src/type_info.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/sqlx-core/src/type_info.rs b/sqlx-core/src/type_info.rs index bf698251..49fcc16b 100644 --- a/sqlx-core/src/type_info.rs +++ b/sqlx-core/src/type_info.rs @@ -1,3 +1,13 @@ use std::fmt::{Debug, Display}; -pub trait TypeInfo: Debug + Display + Clone + PartialEq {} +/// Provides information about a SQL type for the database driver. +/// +/// Currently this only exposes type equality rules that should roughly match the interpretation +/// in a given database (e.g., in PostgreSQL `VARCHAR` and `TEXT` are roughly equivalent +/// apart from storage). +pub trait TypeInfo: Debug + Display + Clone + PartialEq { + /// Returns the database system name of the type. Length specifiers should not be included. + /// Common type names are `VARCHAR`, `TEXT`, or `INT`. Type names should be uppercase. They + /// should be a rough approximation of how they are written in SQL in the given database. + fn name(&self) -> &str; +}