From 3fa749d9e3b25caae5571ff4ebae7d580ddffeb8 Mon Sep 17 00:00:00 2001 From: Ariel Mashraki <7413593+a8m@users.noreply.github.com> Date: Thu, 30 Apr 2020 13:21:00 +0300 Subject: [PATCH] dialect/sql: remove go1.12 support (#457) --- dialect/sql/builder.go | 2 +- dialect/sql/driver.go | 6 ++++-- dialect/sql/sql_112.go | 38 -------------------------------------- dialect/sql/sql_113.go | 12 ------------ 4 files changed, 5 insertions(+), 53 deletions(-) delete mode 100644 dialect/sql/sql_112.go delete mode 100644 dialect/sql/sql_113.go diff --git a/dialect/sql/builder.go b/dialect/sql/builder.go index 25c40c843..c3cef2408 100644 --- a/dialect/sql/builder.go +++ b/dialect/sql/builder.go @@ -14,7 +14,7 @@ import ( "github.com/facebookincubator/ent/dialect" ) -// Querier wraps the basic Query method implemented +// Querier wraps the basic Query method that is implemented // by the different builders in this file. type Querier interface { // Query returns the query representation of the element diff --git a/dialect/sql/driver.go b/dialect/sql/driver.go index 08a34fcd2..deeb7ab26 100644 --- a/dialect/sql/driver.go +++ b/dialect/sql/driver.go @@ -40,8 +40,8 @@ func (d Driver) DB() *sql.DB { // Dialect implements the dialect.Dialect method. func (d Driver) Dialect() string { - // if the underlying driver is wrapped with opencensus driver. - for _, name := range []string{dialect.MySQL, dialect.SQLite} { + // If the underlying driver is wrapped with opencensus driver. + for _, name := range []string{dialect.MySQL, dialect.SQLite, dialect.Postgres} { if strings.HasPrefix(d.dialect, name) { return name } @@ -144,6 +144,8 @@ type ( NullString = sql.NullString // NullFloat64 is an alias to sql.NullFloat64. NullFloat64 = sql.NullFloat64 + // NullTime represents a time.Time that may be null. + NullTime = sql.NullTime // TxOptions holds the transaction options to be used in DB.BeginTx. TxOptions = sql.TxOptions ) diff --git a/dialect/sql/sql_112.go b/dialect/sql/sql_112.go deleted file mode 100644 index eaba44ed3..000000000 --- a/dialect/sql/sql_112.go +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2019-present Facebook Inc. All rights reserved. -// This source code is licensed under the Apache 2.0 license found -// in the LICENSE file in the root directory of this source tree. - -// +build !go1.13 - -package sql - -import ( - "database/sql/driver" - "time" -) - -// NullTime represents a time.Time that may be null. -// -// NullTime implements the Scanner interface so it can -// be used as a scan destination, similar to NullString. -type NullTime struct { - Time time.Time - Valid bool // Valid is true if Time is not NULL -} - -// Scan implements the Scanner interface. -func (n *NullTime) Scan(v interface{}) error { - if v, ok := v.(time.Time); ok { - n.Time = v - n.Valid = true - } - return nil -} - -// Value implements the driver Valuer interface. -func (n NullTime) Value() (driver.Value, error) { - if !n.Valid { - return nil, nil - } - return n.Time, nil -} diff --git a/dialect/sql/sql_113.go b/dialect/sql/sql_113.go deleted file mode 100644 index 999ea4f4a..000000000 --- a/dialect/sql/sql_113.go +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2019-present Facebook Inc. All rights reserved. -// This source code is licensed under the Apache 2.0 license found -// in the LICENSE file in the root directory of this source tree. - -// +build go1.13 - -package sql - -import "database/sql" - -// NullTime represents a time.Time that may be null. -type NullTime = sql.NullTime