good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
U
upper
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
open
upper
Commits
d5effe1f
Commit
d5effe1f
authored
Jun 22, 2014
by
José Carlos Nieto
Browse files
Options
Downloads
Patches
Plain Diff
QL: Mild golint review.
parent
f69511d9
Branches
devnet-70004
Branches containing commit
Tags
v0.2.0-devnet-70004
Tags containing commit
No related merge requests found
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
ql/collection.go
+9
-9
9 additions, 9 deletions
ql/collection.go
ql/database.go
+22
-22
22 additions, 22 deletions
ql/database.go
ql/result.go
+15
-15
15 additions, 15 deletions
ql/result.go
ql/tx.go
+6
-6
6 additions, 6 deletions
ql/tx.go
ql/util.go
+5
-5
5 additions, 5 deletions
ql/util.go
with
57 additions
and
57 deletions
ql/collection.go
+
9
−
9
View file @
d5effe1f
...
@@ -33,10 +33,10 @@ import (
...
@@ -33,10 +33,10 @@ import (
const
defaultOperator
=
`==`
const
defaultOperator
=
`==`
type
T
able
struct
{
type
t
able
struct
{
sqlutil
.
T
sqlutil
.
T
columnTypes
map
[
string
]
reflect
.
Kind
columnTypes
map
[
string
]
reflect
.
Kind
source
*
S
ource
source
*
s
ource
names
[]
string
names
[]
string
}
}
...
@@ -174,10 +174,10 @@ func conditionValues(cond db.Cond) (columnValues sqlgen.ColumnValues, args []int
...
@@ -174,10 +174,10 @@ func conditionValues(cond db.Cond) (columnValues sqlgen.ColumnValues, args []int
return
columnValues
,
args
return
columnValues
,
args
}
}
func
(
self
*
T
able
)
Find
(
terms
...
interface
{})
db
.
Result
{
func
(
self
*
t
able
)
Find
(
terms
...
interface
{})
db
.
Result
{
where
,
arguments
:=
whereValues
(
terms
)
where
,
arguments
:=
whereValues
(
terms
)
result
:=
&
R
esult
{
result
:=
&
r
esult
{
table
:
self
,
table
:
self
,
where
:
where
,
where
:
where
,
arguments
:
arguments
,
arguments
:
arguments
,
...
@@ -186,7 +186,7 @@ func (self *Table) Find(terms ...interface{}) db.Result {
...
@@ -186,7 +186,7 @@ func (self *Table) Find(terms ...interface{}) db.Result {
return
result
return
result
}
}
func
(
self
*
T
able
)
tableN
(
i
int
)
string
{
func
(
self
*
t
able
)
tableN
(
i
int
)
string
{
if
len
(
self
.
names
)
>
i
{
if
len
(
self
.
names
)
>
i
{
chunks
:=
strings
.
SplitN
(
self
.
names
[
i
],
" "
,
2
)
chunks
:=
strings
.
SplitN
(
self
.
names
[
i
],
" "
,
2
)
if
len
(
chunks
)
>
0
{
if
len
(
chunks
)
>
0
{
...
@@ -197,7 +197,7 @@ func (self *Table) tableN(i int) string {
...
@@ -197,7 +197,7 @@ func (self *Table) tableN(i int) string {
}
}
// Deletes all the rows within the collection.
// Deletes all the rows within the collection.
func
(
self
*
T
able
)
Truncate
()
error
{
func
(
self
*
t
able
)
Truncate
()
error
{
_
,
err
:=
self
.
source
.
doExec
(
sqlgen
.
Statement
{
_
,
err
:=
self
.
source
.
doExec
(
sqlgen
.
Statement
{
Type
:
sqlgen
.
SqlTruncate
,
Type
:
sqlgen
.
SqlTruncate
,
...
@@ -212,7 +212,7 @@ func (self *Table) Truncate() error {
...
@@ -212,7 +212,7 @@ func (self *Table) Truncate() error {
}
}
// Appends an item (map or struct) into the collection.
// Appends an item (map or struct) into the collection.
func
(
self
*
T
able
)
Append
(
item
interface
{})
(
interface
{},
error
)
{
func
(
self
*
t
able
)
Append
(
item
interface
{})
(
interface
{},
error
)
{
cols
,
vals
,
err
:=
self
.
FieldValues
(
item
,
toInternal
)
cols
,
vals
,
err
:=
self
.
FieldValues
(
item
,
toInternal
)
...
@@ -250,14 +250,14 @@ func (self *Table) Append(item interface{}) (interface{}, error) {
...
@@ -250,14 +250,14 @@ func (self *Table) Append(item interface{}) (interface{}, error) {
}
}
// Returns true if the collection exists.
// Returns true if the collection exists.
func
(
self
*
T
able
)
Exists
()
bool
{
func
(
self
*
t
able
)
Exists
()
bool
{
if
err
:=
self
.
source
.
tableExists
(
self
.
names
...
);
err
!=
nil
{
if
err
:=
self
.
source
.
tableExists
(
self
.
names
...
);
err
!=
nil
{
return
false
return
false
}
}
return
true
return
true
}
}
func
(
self
*
T
able
)
Name
()
string
{
func
(
self
*
t
able
)
Name
()
string
{
return
strings
.
Join
(
self
.
names
,
`, `
)
return
strings
.
Join
(
self
.
names
,
`, `
)
}
}
...
...
This diff is collapsed.
Click to expand it.
ql/database.go
+
22
−
22
View file @
d5effe1f
...
@@ -52,7 +52,7 @@ var (
...
@@ -52,7 +52,7 @@ var (
sqlPlaceholder
=
sqlgen
.
Value
{
sqlgen
.
Raw
{
`?`
}}
sqlPlaceholder
=
sqlgen
.
Value
{
sqlgen
.
Raw
{
`?`
}}
)
)
type
S
ource
struct
{
type
s
ource
struct
{
config
db
.
Settings
config
db
.
Settings
session
*
sql
.
DB
session
*
sql
.
DB
collections
map
[
string
]
db
.
Collection
collections
map
[
string
]
db
.
Collection
...
@@ -110,10 +110,10 @@ func init() {
...
@@ -110,10 +110,10 @@ func init() {
qlSelectCountLayout
,
qlSelectCountLayout
,
}
}
db
.
Register
(
Adapter
,
&
S
ource
{})
db
.
Register
(
Adapter
,
&
s
ource
{})
}
}
func
(
self
*
S
ource
)
doExec
(
stmt
sqlgen
.
Statement
,
args
...
interface
{})
(
sql
.
Result
,
error
)
{
func
(
self
*
s
ource
)
doExec
(
stmt
sqlgen
.
Statement
,
args
...
interface
{})
(
sql
.
Result
,
error
)
{
var
query
string
var
query
string
var
res
sql
.
Result
var
res
sql
.
Result
...
@@ -155,7 +155,7 @@ func (self *Source) doExec(stmt sqlgen.Statement, args ...interface{}) (sql.Resu
...
@@ -155,7 +155,7 @@ func (self *Source) doExec(stmt sqlgen.Statement, args ...interface{}) (sql.Resu
return
res
,
err
return
res
,
err
}
}
func
(
self
*
S
ource
)
doQuery
(
stmt
sqlgen
.
Statement
,
args
...
interface
{})
(
*
sql
.
Rows
,
error
)
{
func
(
self
*
s
ource
)
doQuery
(
stmt
sqlgen
.
Statement
,
args
...
interface
{})
(
*
sql
.
Rows
,
error
)
{
var
rows
*
sql
.
Rows
var
rows
*
sql
.
Rows
var
query
string
var
query
string
var
err
error
var
err
error
...
@@ -196,7 +196,7 @@ func (self *Source) doQuery(stmt sqlgen.Statement, args ...interface{}) (*sql.Ro
...
@@ -196,7 +196,7 @@ func (self *Source) doQuery(stmt sqlgen.Statement, args ...interface{}) (*sql.Ro
return
rows
,
err
return
rows
,
err
}
}
func
(
self
*
S
ource
)
doQueryRow
(
stmt
sqlgen
.
Statement
,
args
...
interface
{})
(
*
sql
.
Row
,
error
)
{
func
(
self
*
s
ource
)
doQueryRow
(
stmt
sqlgen
.
Statement
,
args
...
interface
{})
(
*
sql
.
Row
,
error
)
{
var
query
string
var
query
string
var
row
*
sql
.
Row
var
row
*
sql
.
Row
var
err
error
var
err
error
...
@@ -238,18 +238,18 @@ func (self *Source) doQueryRow(stmt sqlgen.Statement, args ...interface{}) (*sql
...
@@ -238,18 +238,18 @@ func (self *Source) doQueryRow(stmt sqlgen.Statement, args ...interface{}) (*sql
}
}
// Returns the string name of the database.
// Returns the string name of the database.
func
(
self
*
S
ource
)
Name
()
string
{
func
(
self
*
s
ource
)
Name
()
string
{
return
self
.
config
.
Database
return
self
.
config
.
Database
}
}
// Ping verifies a connection to the database is still alive,
// Ping verifies a connection to the database is still alive,
// establishing a connection if necessary.
// establishing a connection if necessary.
func
(
self
*
S
ource
)
Ping
()
error
{
func
(
self
*
s
ource
)
Ping
()
error
{
return
self
.
session
.
Ping
()
return
self
.
session
.
Ping
()
}
}
func
(
self
*
S
ource
)
clone
()
(
*
S
ource
,
error
)
{
func
(
self
*
s
ource
)
clone
()
(
*
s
ource
,
error
)
{
src
:=
&
S
ource
{}
src
:=
&
s
ource
{}
src
.
Setup
(
self
.
config
)
src
.
Setup
(
self
.
config
)
if
err
:=
src
.
Open
();
err
!=
nil
{
if
err
:=
src
.
Open
();
err
!=
nil
{
...
@@ -259,16 +259,16 @@ func (self *Source) clone() (*Source, error) {
...
@@ -259,16 +259,16 @@ func (self *Source) clone() (*Source, error) {
return
src
,
nil
return
src
,
nil
}
}
func
(
self
*
S
ource
)
Clone
()
(
db
.
Database
,
error
)
{
func
(
self
*
s
ource
)
Clone
()
(
db
.
Database
,
error
)
{
return
self
.
clone
()
return
self
.
clone
()
}
}
func
(
self
*
S
ource
)
Transaction
()
(
db
.
Tx
,
error
)
{
func
(
self
*
s
ource
)
Transaction
()
(
db
.
Tx
,
error
)
{
// We still have some issues with QL, transactions and blocking.
// We still have some issues with QL, transactions and blocking.
return
nil
,
db
.
ErrUnsupported
return
nil
,
db
.
ErrUnsupported
/*
/*
var err error
var err error
var clone *
S
ource
var clone *
s
ource
var sqlTx *sql.Tx
var sqlTx *sql.Tx
if clone, err = self.clone(); err != nil {
if clone, err = self.clone(); err != nil {
...
@@ -288,19 +288,19 @@ func (self *Source) Transaction() (db.Tx, error) {
...
@@ -288,19 +288,19 @@ func (self *Source) Transaction() (db.Tx, error) {
}
}
// Stores database settings.
// Stores database settings.
func
(
self
*
S
ource
)
Setup
(
config
db
.
Settings
)
error
{
func
(
self
*
s
ource
)
Setup
(
config
db
.
Settings
)
error
{
self
.
config
=
config
self
.
config
=
config
self
.
collections
=
make
(
map
[
string
]
db
.
Collection
)
self
.
collections
=
make
(
map
[
string
]
db
.
Collection
)
return
self
.
Open
()
return
self
.
Open
()
}
}
// Returns the underlying *sql.DB instance.
// Returns the underlying *sql.DB instance.
func
(
self
*
S
ource
)
Driver
()
interface
{}
{
func
(
self
*
s
ource
)
Driver
()
interface
{}
{
return
self
.
session
return
self
.
session
}
}
// Attempts to connect to a database using the stored settings.
// Attempts to connect to a database using the stored settings.
func
(
self
*
S
ource
)
Open
()
error
{
func
(
self
*
s
ource
)
Open
()
error
{
var
err
error
var
err
error
if
self
.
config
.
Database
==
""
{
if
self
.
config
.
Database
==
""
{
...
@@ -317,7 +317,7 @@ func (self *Source) Open() error {
...
@@ -317,7 +317,7 @@ func (self *Source) Open() error {
}
}
// Closes the current database session.
// Closes the current database session.
func
(
self
*
S
ource
)
Close
()
error
{
func
(
self
*
s
ource
)
Close
()
error
{
if
self
.
session
!=
nil
{
if
self
.
session
!=
nil
{
return
self
.
session
.
Close
()
return
self
.
session
.
Close
()
}
}
...
@@ -325,13 +325,13 @@ func (self *Source) Close() error {
...
@@ -325,13 +325,13 @@ func (self *Source) Close() error {
}
}
// Changes the active database.
// Changes the active database.
func
(
self
*
S
ource
)
Use
(
database
string
)
error
{
func
(
self
*
s
ource
)
Use
(
database
string
)
error
{
self
.
config
.
Database
=
database
self
.
config
.
Database
=
database
return
self
.
Open
()
return
self
.
Open
()
}
}
// Drops the currently active database.
// Drops the currently active database.
func
(
self
*
S
ource
)
Drop
()
error
{
func
(
self
*
s
ource
)
Drop
()
error
{
_
,
err
:=
self
.
doQuery
(
sqlgen
.
Statement
{
_
,
err
:=
self
.
doQuery
(
sqlgen
.
Statement
{
Type
:
sqlgen
.
SqlDropDatabase
,
Type
:
sqlgen
.
SqlDropDatabase
,
...
@@ -342,7 +342,7 @@ func (self *Source) Drop() error {
...
@@ -342,7 +342,7 @@ func (self *Source) Drop() error {
}
}
// Returns a list of all tables within the currently active database.
// Returns a list of all tables within the currently active database.
func
(
self
*
S
ource
)
Collections
()
([]
string
,
error
)
{
func
(
self
*
s
ource
)
Collections
()
([]
string
,
error
)
{
var
collections
[]
string
var
collections
[]
string
var
collection
string
var
collection
string
...
@@ -368,7 +368,7 @@ func (self *Source) Collections() ([]string, error) {
...
@@ -368,7 +368,7 @@ func (self *Source) Collections() ([]string, error) {
return
collections
,
nil
return
collections
,
nil
}
}
func
(
self
*
S
ource
)
tableExists
(
names
...
string
)
error
{
func
(
self
*
s
ource
)
tableExists
(
names
...
string
)
error
{
for
_
,
name
:=
range
names
{
for
_
,
name
:=
range
names
{
rows
,
err
:=
self
.
doQuery
(
sqlgen
.
Statement
{
rows
,
err
:=
self
.
doQuery
(
sqlgen
.
Statement
{
...
@@ -397,13 +397,13 @@ func (self *Source) tableExists(names ...string) error {
...
@@ -397,13 +397,13 @@ func (self *Source) tableExists(names ...string) error {
}
}
// Returns a collection instance by name.
// Returns a collection instance by name.
func
(
self
*
S
ource
)
Collection
(
names
...
string
)
(
db
.
Collection
,
error
)
{
func
(
self
*
s
ource
)
Collection
(
names
...
string
)
(
db
.
Collection
,
error
)
{
if
len
(
names
)
==
0
{
if
len
(
names
)
==
0
{
return
nil
,
db
.
ErrMissingCollectionName
return
nil
,
db
.
ErrMissingCollectionName
}
}
col
:=
&
T
able
{
col
:=
&
t
able
{
source
:
self
,
source
:
self
,
names
:
names
,
names
:
names
,
}
}
...
...
This diff is collapsed.
Click to expand it.
ql/result.go
+
15
−
15
View file @
d5effe1f
...
@@ -35,8 +35,8 @@ type counter_t struct {
...
@@ -35,8 +35,8 @@ type counter_t struct {
Total
uint64
`db:"total"`
Total
uint64
`db:"total"`
}
}
type
R
esult
struct
{
type
r
esult
struct
{
table
*
T
able
table
*
t
able
cursor
*
sql
.
Rows
// This is the main query cursor. It starts as a nil value.
cursor
*
sql
.
Rows
// This is the main query cursor. It starts as a nil value.
limit
sqlgen
.
Limit
limit
sqlgen
.
Limit
offset
sqlgen
.
Offset
offset
sqlgen
.
Offset
...
@@ -47,7 +47,7 @@ type Result struct {
...
@@ -47,7 +47,7 @@ type Result struct {
}
}
// Executes a SELECT statement that can feed Next(), All() or One().
// Executes a SELECT statement that can feed Next(), All() or One().
func
(
self
*
R
esult
)
setCursor
()
error
{
func
(
self
*
r
esult
)
setCursor
()
error
{
var
err
error
var
err
error
// We need a cursor, if the cursor does not exists yet then we create one.
// We need a cursor, if the cursor does not exists yet then we create one.
if
self
.
cursor
==
nil
{
if
self
.
cursor
==
nil
{
...
@@ -64,20 +64,20 @@ func (self *Result) setCursor() error {
...
@@ -64,20 +64,20 @@ func (self *Result) setCursor() error {
}
}
// Sets conditions for reducing the working set.
// Sets conditions for reducing the working set.
func
(
self
*
R
esult
)
Where
(
terms
...
interface
{})
db
.
Result
{
func
(
self
*
r
esult
)
Where
(
terms
...
interface
{})
db
.
Result
{
self
.
where
,
self
.
arguments
=
whereValues
(
terms
)
self
.
where
,
self
.
arguments
=
whereValues
(
terms
)
return
self
return
self
}
}
// Determines the maximum limit of results to be returned.
// Determines the maximum limit of results to be returned.
func
(
self
*
R
esult
)
Limit
(
n
uint
)
db
.
Result
{
func
(
self
*
r
esult
)
Limit
(
n
uint
)
db
.
Result
{
self
.
limit
=
sqlgen
.
Limit
(
n
)
self
.
limit
=
sqlgen
.
Limit
(
n
)
return
self
return
self
}
}
// Determines how many documents will be skipped before starting to grab
// Determines how many documents will be skipped before starting to grab
// results.
// results.
func
(
self
*
R
esult
)
Skip
(
n
uint
)
db
.
Result
{
func
(
self
*
r
esult
)
Skip
(
n
uint
)
db
.
Result
{
self
.
offset
=
sqlgen
.
Offset
(
n
)
self
.
offset
=
sqlgen
.
Offset
(
n
)
return
self
return
self
}
}
...
@@ -85,7 +85,7 @@ func (self *Result) Skip(n uint) db.Result {
...
@@ -85,7 +85,7 @@ func (self *Result) Skip(n uint) db.Result {
// Determines sorting of results according to the provided names. Fields may be
// Determines sorting of results according to the provided names. Fields may be
// prefixed by - (minus) which means descending order, ascending order would be
// prefixed by - (minus) which means descending order, ascending order would be
// used otherwise.
// used otherwise.
func
(
self
*
R
esult
)
Sort
(
fields
...
string
)
db
.
Result
{
func
(
self
*
r
esult
)
Sort
(
fields
...
string
)
db
.
Result
{
sortColumns
:=
make
(
sqlgen
.
SortColumns
,
0
,
len
(
fields
))
sortColumns
:=
make
(
sqlgen
.
SortColumns
,
0
,
len
(
fields
))
...
@@ -115,7 +115,7 @@ func (self *Result) Sort(fields ...string) db.Result {
...
@@ -115,7 +115,7 @@ func (self *Result) Sort(fields ...string) db.Result {
}
}
// Retrieves only the given fields.
// Retrieves only the given fields.
func
(
self
*
R
esult
)
Select
(
fields
...
interface
{})
db
.
Result
{
func
(
self
*
r
esult
)
Select
(
fields
...
interface
{})
db
.
Result
{
self
.
columns
=
make
(
sqlgen
.
Columns
,
0
,
len
(
fields
))
self
.
columns
=
make
(
sqlgen
.
Columns
,
0
,
len
(
fields
))
l
:=
len
(
fields
)
l
:=
len
(
fields
)
...
@@ -132,7 +132,7 @@ func (self *Result) Select(fields ...interface{}) db.Result {
...
@@ -132,7 +132,7 @@ func (self *Result) Select(fields ...interface{}) db.Result {
}
}
// Dumps all results into a pointer to an slice of structs or maps.
// Dumps all results into a pointer to an slice of structs or maps.
func
(
self
*
R
esult
)
All
(
dst
interface
{})
error
{
func
(
self
*
r
esult
)
All
(
dst
interface
{})
error
{
var
err
error
var
err
error
if
self
.
cursor
!=
nil
{
if
self
.
cursor
!=
nil
{
...
@@ -155,7 +155,7 @@ func (self *Result) All(dst interface{}) error {
...
@@ -155,7 +155,7 @@ func (self *Result) All(dst interface{}) error {
}
}
// Fetches only one result from the resultset.
// Fetches only one result from the resultset.
func
(
self
*
R
esult
)
One
(
dst
interface
{})
error
{
func
(
self
*
r
esult
)
One
(
dst
interface
{})
error
{
var
err
error
var
err
error
if
self
.
cursor
!=
nil
{
if
self
.
cursor
!=
nil
{
...
@@ -170,7 +170,7 @@ func (self *Result) One(dst interface{}) error {
...
@@ -170,7 +170,7 @@ func (self *Result) One(dst interface{}) error {
}
}
// Fetches the next result from the resultset.
// Fetches the next result from the resultset.
func
(
self
*
R
esult
)
Next
(
dst
interface
{})
error
{
func
(
self
*
r
esult
)
Next
(
dst
interface
{})
error
{
var
err
error
var
err
error
...
@@ -192,7 +192,7 @@ func (self *Result) Next(dst interface{}) error {
...
@@ -192,7 +192,7 @@ func (self *Result) Next(dst interface{}) error {
}
}
// Removes the matching items from the collection.
// Removes the matching items from the collection.
func
(
self
*
R
esult
)
Remove
()
error
{
func
(
self
*
r
esult
)
Remove
()
error
{
var
err
error
var
err
error
_
,
err
=
self
.
table
.
source
.
doExec
(
sqlgen
.
Statement
{
_
,
err
=
self
.
table
.
source
.
doExec
(
sqlgen
.
Statement
{
Type
:
sqlgen
.
SqlDelete
,
Type
:
sqlgen
.
SqlDelete
,
...
@@ -205,7 +205,7 @@ func (self *Result) Remove() error {
...
@@ -205,7 +205,7 @@ func (self *Result) Remove() error {
// Updates matching items from the collection with values of the given map or
// Updates matching items from the collection with values of the given map or
// struct.
// struct.
func
(
self
*
R
esult
)
Update
(
values
interface
{})
error
{
func
(
self
*
r
esult
)
Update
(
values
interface
{})
error
{
ff
,
vv
,
err
:=
self
.
table
.
FieldValues
(
values
,
toInternal
)
ff
,
vv
,
err
:=
self
.
table
.
FieldValues
(
values
,
toInternal
)
...
@@ -230,7 +230,7 @@ func (self *Result) Update(values interface{}) error {
...
@@ -230,7 +230,7 @@ func (self *Result) Update(values interface{}) error {
}
}
// Closes the result set.
// Closes the result set.
func
(
self
*
R
esult
)
Close
()
error
{
func
(
self
*
r
esult
)
Close
()
error
{
var
err
error
var
err
error
if
self
.
cursor
!=
nil
{
if
self
.
cursor
!=
nil
{
err
=
self
.
cursor
.
Close
()
err
=
self
.
cursor
.
Close
()
...
@@ -240,7 +240,7 @@ func (self *Result) Close() error {
...
@@ -240,7 +240,7 @@ func (self *Result) Close() error {
}
}
// Counts matching elements.
// Counts matching elements.
func
(
self
*
R
esult
)
Count
()
(
uint64
,
error
)
{
func
(
self
*
r
esult
)
Count
()
(
uint64
,
error
)
{
rows
,
err
:=
self
.
table
.
source
.
doQuery
(
sqlgen
.
Statement
{
rows
,
err
:=
self
.
table
.
source
.
doQuery
(
sqlgen
.
Statement
{
Type
:
sqlgen
.
SqlSelectCount
,
Type
:
sqlgen
.
SqlSelectCount
,
...
...
This diff is collapsed.
Click to expand it.
ql/tx.go
+
6
−
6
View file @
d5effe1f
...
@@ -21,14 +21,14 @@
...
@@ -21,14 +21,14 @@
package
ql
package
ql
type
T
x
struct
{
type
t
x
struct
{
*
S
ource
*
s
ource
}
}
func
(
self
*
T
x
)
Commit
()
error
{
func
(
self
*
t
x
)
Commit
()
error
{
return
self
.
S
ource
.
tx
.
Commit
()
return
self
.
s
ource
.
tx
.
Commit
()
}
}
func
(
self
*
T
x
)
Rollback
()
error
{
func
(
self
*
t
x
)
Rollback
()
error
{
return
self
.
S
ource
.
tx
.
Rollback
()
return
self
.
s
ource
.
tx
.
Rollback
()
}
}
This diff is collapsed.
Click to expand it.
ql/util.go
+
5
−
5
View file @
d5effe1f
...
@@ -41,14 +41,14 @@ func getRowColumns(rows *sql.Rows) ([]string, error) {
...
@@ -41,14 +41,14 @@ func getRowColumns(rows *sql.Rows) ([]string, error) {
}
}
// Column names to lower case.
// Column names to lower case.
for
i
,
_
:=
range
columns
{
for
i
:=
range
columns
{
columns
[
i
]
=
strings
.
ToLower
(
columns
[
i
])
columns
[
i
]
=
strings
.
ToLower
(
columns
[
i
])
}
}
return
columns
,
nil
return
columns
,
nil
}
}
func
(
self
*
T
able
)
fetchRow
(
rows
*
sql
.
Rows
,
dst
interface
{})
error
{
func
(
self
*
t
able
)
fetchRow
(
rows
*
sql
.
Rows
,
dst
interface
{})
error
{
var
err
error
var
err
error
dstv
:=
reflect
.
ValueOf
(
dst
)
dstv
:=
reflect
.
ValueOf
(
dst
)
...
@@ -85,7 +85,7 @@ func (self *Table) fetchRow(rows *sql.Rows, dst interface{}) error {
...
@@ -85,7 +85,7 @@ func (self *Table) fetchRow(rows *sql.Rows, dst interface{}) error {
return
nil
return
nil
}
}
func
(
self
*
T
able
)
fetchResult
(
item_t
reflect
.
Type
,
rows
*
sql
.
Rows
,
columns
[]
string
)
(
item
reflect
.
Value
,
err
error
)
{
func
(
self
*
t
able
)
fetchResult
(
item_t
reflect
.
Type
,
rows
*
sql
.
Rows
,
columns
[]
string
)
(
item
reflect
.
Value
,
err
error
)
{
expecting
:=
len
(
columns
)
expecting
:=
len
(
columns
)
scanArgs
:=
make
([]
interface
{},
expecting
)
scanArgs
:=
make
([]
interface
{},
expecting
)
...
@@ -113,7 +113,7 @@ func (self *Table) fetchResult(item_t reflect.Type, rows *sql.Rows, columns []st
...
@@ -113,7 +113,7 @@ func (self *Table) fetchResult(item_t reflect.Type, rows *sql.Rows, columns []st
}
}
case
reflect
.
Map
:
case
reflect
.
Map
:
values
:=
make
([]
*
sql
.
RawBytes
,
len
(
columns
))
values
:=
make
([]
*
sql
.
RawBytes
,
len
(
columns
))
for
i
,
_
:=
range
columns
{
for
i
:=
range
columns
{
scanArgs
[
i
]
=
&
values
[
i
]
scanArgs
[
i
]
=
&
values
[
i
]
}
}
err
=
rows
.
Scan
(
scanArgs
...
)
err
=
rows
.
Scan
(
scanArgs
...
)
...
@@ -146,7 +146,7 @@ func (self *Table) fetchResult(item_t reflect.Type, rows *sql.Rows, columns []st
...
@@ -146,7 +146,7 @@ func (self *Table) fetchResult(item_t reflect.Type, rows *sql.Rows, columns []st
return
item
,
nil
return
item
,
nil
}
}
func
(
self
*
T
able
)
fetchRows
(
rows
*
sql
.
Rows
,
dst
interface
{})
error
{
func
(
self
*
t
able
)
fetchRows
(
rows
*
sql
.
Rows
,
dst
interface
{})
error
{
var
err
error
var
err
error
// Destination.
// Destination.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment