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
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
1
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
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
bd5bf8bc
Commit
bd5bf8bc
authored
9 years ago
by
José Carlos Nieto
Browse files
Options
Downloads
Patches
Plain Diff
Removing custom tx (duplicated functionality).
parent
be92d139
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
internal/sqladapter/database.go
+4
-1
4 additions, 1 deletion
internal/sqladapter/database.go
internal/sqlutil/tx/tx.go
+6
-0
6 additions, 0 deletions
internal/sqlutil/tx/tx.go
postgresql/database.go
+2
-1
2 additions, 1 deletion
postgresql/database.go
postgresql/tx.go
+0
-58
0 additions, 58 deletions
postgresql/tx.go
with
12 additions
and
60 deletions
internal/sqladapter/database.go
+
4
−
1
View file @
bd5bf8bc
...
@@ -34,9 +34,9 @@ type Database interface {
...
@@ -34,9 +34,9 @@ type Database interface {
type
BaseDatabase
struct
{
type
BaseDatabase
struct
{
partial
PartialDatabase
partial
PartialDatabase
sess
*
sqlx
.
DB
sess
*
sqlx
.
DB
tx
*
sqltx
.
Tx
connURL
db
.
ConnectionURL
connURL
db
.
ConnectionURL
tx
*
sqltx
.
Tx
schema
*
schema
.
DatabaseSchema
schema
*
schema
.
DatabaseSchema
cachedStatements
*
cache
.
Cache
cachedStatements
*
cache
.
Cache
collections
map
[
string
]
db
.
Collection
collections
map
[
string
]
db
.
Collection
...
@@ -250,6 +250,9 @@ func (d *BaseDatabase) Builder() db.QueryBuilder {
...
@@ -250,6 +250,9 @@ func (d *BaseDatabase) Builder() db.QueryBuilder {
// Driver returns the underlying *sqlx.DB instance.
// Driver returns the underlying *sqlx.DB instance.
func
(
d
*
BaseDatabase
)
Driver
()
interface
{}
{
func
(
d
*
BaseDatabase
)
Driver
()
interface
{}
{
if
d
.
tx
!=
nil
{
return
d
.
tx
.
Tx
}
return
d
.
sess
return
d
.
sess
}
}
...
...
This diff is collapsed.
Click to expand it.
internal/sqlutil/tx/tx.go
+
6
−
0
View file @
bd5bf8bc
...
@@ -23,8 +23,14 @@ package sqltx
...
@@ -23,8 +23,14 @@ package sqltx
import
(
import
(
"github.com/jmoiron/sqlx"
"github.com/jmoiron/sqlx"
"upper.io/db"
)
)
type
Database
struct
{
db
.
Database
*
Tx
}
type
Tx
struct
{
type
Tx
struct
{
*
sqlx
.
Tx
*
sqlx
.
Tx
done
bool
done
bool
...
...
This diff is collapsed.
Click to expand it.
postgresql/database.go
+
2
−
1
View file @
bd5bf8bc
...
@@ -30,6 +30,7 @@ import (
...
@@ -30,6 +30,7 @@ import (
"upper.io/builder/sqlgen"
"upper.io/builder/sqlgen"
"upper.io/db"
"upper.io/db"
"upper.io/db/internal/sqladapter"
"upper.io/db/internal/sqladapter"
"upper.io/db/internal/sqlutil/tx"
)
)
type
database
struct
{
type
database
struct
{
...
@@ -174,7 +175,7 @@ func (d *database) Transaction() (db.Tx, error) {
...
@@ -174,7 +175,7 @@ func (d *database) Transaction() (db.Tx, error) {
clone
.
BindTx
(
sqlTx
)
clone
.
BindTx
(
sqlTx
)
return
&
tx
{
Tx
:
clone
.
Tx
(),
database
:
clone
},
nil
return
&
sqltx
.
Database
{
Database
:
clone
,
Tx
:
clone
.
Tx
()
},
nil
}
}
// PopulateSchema looks up for the table info in the database and populates its
// PopulateSchema looks up for the table info in the database and populates its
...
...
This diff is collapsed.
Click to expand it.
postgresql/tx.go
deleted
100644 → 0
+
0
−
58
View file @
be92d139
// Copyright (c) 2012-2015 The upper.io/db authors. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package
postgresql
import
(
"upper.io/db"
"upper.io/db/internal/sqlutil/tx"
)
type
tx
struct
{
*
sqltx
.
Tx
*
database
}
var
_
=
db
.
Tx
(
&
tx
{})
// Driver returns the current transaction session.
func
(
t
*
tx
)
Driver
()
interface
{}
{
if
t
!=
nil
&&
t
.
Tx
!=
nil
{
return
t
.
Tx
.
Tx
}
return
nil
}
// Commit commits the current transaction.
func
(
t
*
tx
)
Commit
()
error
{
if
err
:=
t
.
Tx
.
Commit
();
err
!=
nil
{
return
err
}
return
nil
}
// Rollback discards the current transaction.
func
(
t
*
tx
)
Rollback
()
error
{
if
err
:=
t
.
Tx
.
Rollback
();
err
!=
nil
{
return
err
}
return
nil
}
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