dialect/sql: remove go1.12 support (#457)

This commit is contained in:
Ariel Mashraki
2020-04-30 13:21:00 +03:00
committed by GitHub
parent 7de4f4b758
commit 3fa749d9e3
4 changed files with 5 additions and 53 deletions

View File

@@ -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

View File

@@ -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
)

View File

@@ -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
}

View File

@@ -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