From b988b2c890334c971193c2520fa844dd41cfcace Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Thu, 5 Apr 2018 00:35:08 +0100 Subject: [PATCH] =?UTF-8?q?Remove=20=E2=80=98url=E2=80=99=20and=20?= =?UTF-8?q?=E2=80=98color=E2=80=99=20SQL=20field=20types?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/sql.go | 11 +++++------ sql/sql_test.go | 13 ++----------- util/conv/conv.go | 20 -------------------- 3 files changed, 7 insertions(+), 37 deletions(-) diff --git a/sql/sql.go b/sql/sql.go index efbaab06..1fc2d637 100644 --- a/sql/sql.go +++ b/sql/sql.go @@ -34,12 +34,11 @@ const ( var ( allowedTypes = []string{ "array", "boolean", "circle", - "color", "datetime", "domain", - "double", "email", "latitude", - "longitude", "number", "object", - "password", "phone", "point", - "polygon", "record", "string", - "url", "uuid", + "datetime", "domain", "double", + "email", "latitude", "longitude", + "number", "object", "password", + "phone", "point", "polygon", + "record", "string", "uuid", } allowedAlgorithms = []string{ diff --git a/sql/sql_test.go b/sql/sql_test.go index 62152472..1b7b187b 100644 --- a/sql/sql_test.go +++ b/sql/sql_test.go @@ -2694,20 +2694,11 @@ func Test_Parse_Queries_Define(t *testing.T) { }, { sql: `DEFINE FIELD temp ON person TYPE`, - err: "Found `` but expected `array, boolean, circle, color, datetime, domain, double, email, latitude, longitude, number, object, password, phone, point, polygon, record, string, url, uuid`", + err: "Found `` but expected `array, boolean, circle, datetime, domain, double, email, latitude, longitude, number, object, password, phone, point, polygon, record, string, uuid`", }, { sql: `DEFINE FIELD temp ON person TYPE something`, - err: "Found `something` but expected `array, boolean, circle, color, datetime, domain, double, email, latitude, longitude, number, object, password, phone, point, polygon, record, string, url, uuid`", - }, - { - sql: `DEFINE FIELD temp ON person TYPE url`, - res: &Query{Statements: []Statement{&DefineFieldStatement{ - KV: "*", NS: "*", DB: "*", - Name: &Ident{"temp"}, - What: Tables{&Table{"person"}}, - Type: "url", - }}}, + err: "Found `something` but expected `array, boolean, circle, datetime, domain, double, email, latitude, longitude, number, object, password, phone, point, polygon, record, string, uuid`", }, { sql: `DEFINE FIELD temp ON person TYPE email`, diff --git a/util/conv/conv.go b/util/conv/conv.go index a737f5fa..9c22c232 100644 --- a/util/conv/conv.go +++ b/util/conv/conv.go @@ -87,12 +87,8 @@ func ConvertTo(t, k string, obj interface{}) (val interface{}, err error) { switch t { default: return obj, nil - case "url": - return ConvertToUrl(obj) case "uuid": return ConvertToUuid(obj) - case "color": - return ConvertToColor(obj) case "email": return ConvertToEmail(obj) case "phone": @@ -124,14 +120,6 @@ func ConvertTo(t, k string, obj interface{}) (val interface{}, err error) { } } -func ConvertToUrl(obj interface{}) (val string, err error) { - val = fmt.Sprintf("%v", obj) - if !govalidator.IsURL(val) { - err = fmt.Errorf("Expected a URL, but found '%v'", obj) - } - return -} - func ConvertToUuid(obj interface{}) (val string, err error) { val = fmt.Sprintf("%v", obj) if !govalidator.IsUUID(val) { @@ -156,14 +144,6 @@ func ConvertToPhone(obj interface{}) (val string, err error) { return } -func ConvertToColor(obj interface{}) (val string, err error) { - val = fmt.Sprintf("%v", obj) - if !govalidator.IsHexcolor(val) && !govalidator.IsRGBcolor(val) { - err = fmt.Errorf("Expected a HEX or RGB color, but found '%v'", obj) - } - return -} - func ConvertToArray(obj interface{}) (val []interface{}, err error) { if now, ok := obj.([]interface{}); ok { val = now