Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
xiam committed Jun 23, 2024
1 parent 6a4852d commit 09c8392
Show file tree
Hide file tree
Showing 19 changed files with 57 additions and 43 deletions.
14 changes: 7 additions & 7 deletions adapter/cockroachdb/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ func (vs values) Isset(k string) bool {
//
// You can use a ConnectionURL struct as an argument for Open:
//
// var settings = cockroachdb.ConnectionURL{
// Host: "localhost", // Database server IP or host name.
// Database: "peanuts", // Database name.
// User: "cbrown", // Optional user name.
// Password: "snoopy", // Optional user password.
// }
// var settings = cockroachdb.ConnectionURL{
// Host: "localhost", // Database server IP or host name.
// Database: "peanuts", // Database name.
// User: "cbrown", // Optional user name.
// Password: "snoopy", // Optional user password.
// }
//
// sess, err = cockroachdb.Open(settings)
// sess, err = cockroachdb.Open(settings)
//
// If you already have a valid DSN, you can use ParseURL to convert it into
// a ConnectionURL before passing it to Open.
Expand Down
1 change: 1 addition & 0 deletions adapter/cockroachdb/custom_types_pgx.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !pq
// +build !pq

// Copyright (c) 2012-present The upper.io/db authors. All rights reserved.
Expand Down
1 change: 1 addition & 0 deletions adapter/cockroachdb/custom_types_pq.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build pq
// +build pq

// Copyright (c) 2012-present The upper.io/db authors. All rights reserved.
Expand Down
3 changes: 2 additions & 1 deletion adapter/cockroachdb/database_pgx.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ import (
"context"
"database/sql"

"time"

_ "github.com/jackc/pgx/v4/stdlib"
"github.com/upper/db/v4"
"github.com/upper/db/v4/internal/sqladapter"
"time"
)

func (*database) OpenDSN(sess sqladapter.Session, dsn string) (*sql.DB, error) {
Expand Down
4 changes: 3 additions & 1 deletion adapter/cockroachdb/database_pq.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ package cockroachdb
import (
"context"
"database/sql"
"time"

_ "github.com/lib/pq"
db "github.com/upper/db/v4"
"github.com/upper/db/v4/internal/sqladapter"
"time"
)

func (*database) OpenDSN(sess sqladapter.Session, dsn string) (*sql.DB, error) {
Expand Down
12 changes: 6 additions & 6 deletions adapter/mysql/custom_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,12 @@ func DecodeJSON(dst interface{}, src interface{}) error {
//
// Example:
//
// type MyCustomStruct struct {
// ID int64 `db:"id" json:"id"`
// Name string `db:"name" json:"name"`
// ...
// mysql.JSONConverter
// }
// type MyCustomStruct struct {
// ID int64 `db:"id" json:"id"`
// Name string `db:"name" json:"name"`
// ...
// mysql.JSONConverter
// }
type JSONConverter struct{}

func (*JSONConverter) ConvertValue(in interface{}) interface {
Expand Down
18 changes: 9 additions & 9 deletions adapter/postgresql/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ func (vs values) Isset(k string) bool {
//
// You can use a ConnectionURL struct as an argument for Open:
//
// var settings = postgresql.ConnectionURL{
// Host: "localhost", // PostgreSQL server IP or name.
// Database: "peanuts", // Database name.
// User: "cbrown", // Optional user name.
// Password: "snoopy", // Optional user password.
// }
// var settings = postgresql.ConnectionURL{
// Host: "localhost", // PostgreSQL server IP or name.
// Database: "peanuts", // Database name.
// User: "cbrown", // Optional user name.
// Password: "snoopy", // Optional user password.
// }
//
// sess, err = postgresql.Open(settings)
// sess, err = postgresql.Open(settings)
//
// If you already have a valid DSN, you can use ParseURL to convert it into
// a ConnectionURL before passing it to Open.
Expand All @@ -104,7 +104,7 @@ var escaper = strings.NewReplacer(` `, `\ `, `'`, `\'`, `\`, `\\`)
// ParseURL parses the given DSN into a ConnectionURL struct.
// A typical PostgreSQL connection URL looks like:
//
// postgres://bob:[email protected]:5432/mydb?sslmode=verify-full
// postgres://bob:[email protected]:5432/mydb?sslmode=verify-full
func ParseURL(s string) (u *ConnectionURL, err error) {
o := make(values)

Expand Down Expand Up @@ -260,7 +260,7 @@ func newScanner(s string) *scanner {
//
// "postgres://"
//
// This will be blank, causing driver.Open to use all of the defaults
// # This will be blank, causing driver.Open to use all of the defaults
//
// NOTE: vendored/copied from github.com/lib/pq
func parseURL(uri string) (string, error) {
Expand Down
1 change: 1 addition & 0 deletions adapter/postgresql/custom_types_pgx.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !pq
// +build !pq

// Copyright (c) 2012-present The upper.io/db authors. All rights reserved.
Expand Down
1 change: 1 addition & 0 deletions adapter/postgresql/custom_types_pq.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build pq
// +build pq

package postgresql
Expand Down
3 changes: 2 additions & 1 deletion adapter/postgresql/database_pgx.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ package postgresql
import (
"context"
"database/sql"
"time"

_ "github.com/jackc/pgx/v4/stdlib"
"github.com/upper/db/v4"
"github.com/upper/db/v4/internal/sqladapter"
"time"
)

func (*database) OpenDSN(sess sqladapter.Session, dsn string) (*sql.DB, error) {
Expand Down
4 changes: 3 additions & 1 deletion adapter/postgresql/database_pq.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ package postgresql
import (
"context"
"database/sql"
"time"

_ "github.com/lib/pq"
db "github.com/upper/db/v4"
"github.com/upper/db/v4/internal/sqladapter"
"time"
)

func (*database) OpenDSN(sess sqladapter.Session, dsn string) (*sql.DB, error) {
Expand Down
3 changes: 2 additions & 1 deletion adapter/ql/connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@
package ql

import (
"github.com/stretchr/testify/assert"
"path/filepath"
"testing"

"github.com/stretchr/testify/assert"
)

func TestConnectionURL(t *testing.T) {
Expand Down
20 changes: 10 additions & 10 deletions cond.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,20 @@ type LogicalOperator = adapter.LogicalOperator
//
// Examples:
//
// // Age equals 18.
// db.Cond{"age": 18}
// // Age equals 18.
// db.Cond{"age": 18}
//
// // Age is greater than or equal to 18.
// db.Cond{"age >=": 18}
// // Age is greater than or equal to 18.
// db.Cond{"age >=": 18}
//
// // id is any of the values 1, 2 or 3.
// db.Cond{"id IN": []{1, 2, 3}}
// // id is any of the values 1, 2 or 3.
// db.Cond{"id IN": []{1, 2, 3}}
//
// // Age is lower than 18 (MongoDB syntax)
// db.Cond{"age $lt": 18}
// // Age is lower than 18 (MongoDB syntax)
// db.Cond{"age $lt": 18}
//
// // age > 32 and age < 35
// db.Cond{"age >": 32, "age <": 35}
// // age > 32 and age < 35
// db.Cond{"age >": 32, "age <": 35}
type Cond map[interface{}]interface{}

// Empty returns false if there are no conditions.
Expand Down
1 change: 1 addition & 0 deletions internal/sqladapter/compat/query.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !go1.8
// +build !go1.8

package compat
Expand Down
1 change: 1 addition & 0 deletions internal/sqladapter/compat/query_go18.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build go1.8
// +build go1.8

package compat
Expand Down
3 changes: 2 additions & 1 deletion internal/sqladapter/exql/column_value.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package exql

import (
"github.com/upper/db/v4/internal/cache"
"strings"

"github.com/upper/db/v4/internal/cache"
)

// ColumnValue represents a bundle between a column and a corresponding value.
Expand Down
2 changes: 1 addition & 1 deletion internal/sqladapter/exql/statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

var errUnknownTemplateType = errors.New("Unknown template type")

// represents different kinds of SQL statements.
// represents different kinds of SQL statements.
type Statement struct {
Type
Table Fragment
Expand Down
1 change: 1 addition & 0 deletions internal/sqlbuilder/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (

"database/sql"
"database/sql/driver"

db "github.com/upper/db/v4"
"github.com/upper/db/v4/internal/reflectx"
)
Expand Down
7 changes: 3 additions & 4 deletions sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,11 @@ import (
// pointer, if you want to build a query using variables you need to reassign
// them, like this:
//
// a = builder.Select("name").From("foo") // "a" is created
// a = builder.Select("name").From("foo") // "a" is created
//
// a.Where(...) // No effect, the value returned from Where is ignored.
//
// a = a.Where(...) // "a" is reassigned and points to a different address.
// a.Where(...) // No effect, the value returned from Where is ignored.
//
// a = a.Where(...) // "a" is reassigned and points to a different address.
type SQL interface {

// Select initializes and returns a Selector, it accepts column names as
Expand Down

0 comments on commit 09c8392

Please sign in to comment.