Move DriverUsesLastInsertID to correct package
This commit is contained in:
parent
bd92e49ff0
commit
799c35125f
5 changed files with 24 additions and 24 deletions
|
@ -69,7 +69,7 @@ func Tables(db Interface, names ...string) ([]Table, error) {
|
||||||
return tables, nil
|
return tables, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// setIsJoinTable iff there are:
|
// setIsJoinTable if there are:
|
||||||
// A composite primary key involving two columns
|
// A composite primary key involving two columns
|
||||||
// Both primary key columns are also foreign keys
|
// Both primary key columns are also foreign keys
|
||||||
func setIsJoinTable(t *Table) {
|
func setIsJoinTable(t *Table) {
|
||||||
|
@ -109,3 +109,14 @@ func setForeignKeyConstraints(t *Table, tables []Table) {
|
||||||
func setRelationships(t *Table, tables []Table) {
|
func setRelationships(t *Table, tables []Table) {
|
||||||
t.ToManyRelationships = toManyRelationships(*t, tables)
|
t.ToManyRelationships = toManyRelationships(*t, tables)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DriverUsesLastInsertID returns whether the database driver
|
||||||
|
// supports the sql.Result interface.
|
||||||
|
func DriverUsesLastInsertID(driverName string) bool {
|
||||||
|
switch driverName {
|
||||||
|
case "postgres":
|
||||||
|
return false
|
||||||
|
default:
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -223,3 +223,14 @@ func TestSetRelationships(t *testing.T) {
|
||||||
t.Error("should not be a join table")
|
t.Error("should not be a join table")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestDriverUsesLastInsertID(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
if DriverUsesLastInsertID("postgres") {
|
||||||
|
t.Error("postgres does not support LastInsertId")
|
||||||
|
}
|
||||||
|
if !DriverUsesLastInsertID("mysql") {
|
||||||
|
t.Error("postgres does support LastInsertId")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -313,17 +313,6 @@ func WhereClause(start int, cols []string) string {
|
||||||
return buf.String()
|
return buf.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
// DriverUsesLastInsertID returns whether the database driver supports the
|
|
||||||
// sql.Result interface.
|
|
||||||
func DriverUsesLastInsertID(driverName string) bool {
|
|
||||||
switch driverName {
|
|
||||||
case "postgres":
|
|
||||||
return false
|
|
||||||
default:
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Substring returns a substring of str starting at index start and going
|
// Substring returns a substring of str starting at index start and going
|
||||||
// to end-1.
|
// to end-1.
|
||||||
func Substring(start, end int, str string) string {
|
func Substring(start, end int, str string) string {
|
||||||
|
|
|
@ -69,17 +69,6 @@ func TestIdentifier(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDriverUsesLastInsertID(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
if DriverUsesLastInsertID("postgres") {
|
|
||||||
t.Error("postgres does not support LastInsertId")
|
|
||||||
}
|
|
||||||
if !DriverUsesLastInsertID("mysql") {
|
|
||||||
t.Error("postgres does support LastInsertId")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestPlaceholders(t *testing.T) {
|
func TestPlaceholders(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
|
|
|
@ -165,8 +165,8 @@ var templateFunctions = template.FuncMap{
|
||||||
"textsFromRelationship": textsFromRelationship,
|
"textsFromRelationship": textsFromRelationship,
|
||||||
|
|
||||||
// dbdrivers ops
|
// dbdrivers ops
|
||||||
"driverUsesLastInsertID": strmangle.DriverUsesLastInsertID,
|
|
||||||
"makeDBName": strmangle.MakeDBName,
|
"makeDBName": strmangle.MakeDBName,
|
||||||
|
"driverUsesLastInsertID": bdb.DriverUsesLastInsertID,
|
||||||
"filterColumnsByDefault": bdb.FilterColumnsByDefault,
|
"filterColumnsByDefault": bdb.FilterColumnsByDefault,
|
||||||
"filterColumnsBySimpleDefault": bdb.FilterColumnsBySimpleDefault,
|
"filterColumnsBySimpleDefault": bdb.FilterColumnsBySimpleDefault,
|
||||||
"filterColumnsByAutoIncrement": bdb.FilterColumnsByAutoIncrement,
|
"filterColumnsByAutoIncrement": bdb.FilterColumnsByAutoIncrement,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue