Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
c0619ef4
Unverified
Commit
c0619ef4
authored
Oct 08, 2023
by
Athurg Gooth
Committed by
GitHub
Oct 08, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: CreateIdentityProvider without id (#2352)
parent
b2aa66b4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
29 deletions
+20
-29
idp.go
store/db/mysql/idp.go
+10
-9
idp.go
store/db/sqlite/idp.go
+10
-20
No files found.
store/db/mysql/idp.go
View file @
c0619ef4
...
@@ -22,15 +22,16 @@ func (d *DB) CreateIdentityProvider(ctx context.Context, create *store.IdentityP
...
@@ -22,15 +22,16 @@ func (d *DB) CreateIdentityProvider(ctx context.Context, create *store.IdentityP
return
nil
,
errors
.
Errorf
(
"unsupported idp type %s"
,
string
(
create
.
Type
))
return
nil
,
errors
.
Errorf
(
"unsupported idp type %s"
,
string
(
create
.
Type
))
}
}
stmt
:=
"INSERT INTO `idp` (`name`, `type`, `identifier_filter`, `config`) VALUES (?, ?, ?, ?)"
placeholders
:=
[]
string
{
"?"
,
"?"
,
"?"
,
"?"
}
result
,
err
:=
d
.
db
.
ExecContext
(
fields
:=
[]
string
{
"`name`"
,
"`type`"
,
"`identifier_filter`"
,
"`config`"
}
ctx
,
args
:=
[]
any
{
create
.
Name
,
create
.
Type
,
create
.
IdentifierFilter
,
string
(
configBytes
)}
stmt
,
create
.
Name
,
if
create
.
ID
!=
0
{
create
.
Type
,
fields
,
placeholders
,
args
=
append
(
fields
,
"`id`"
),
append
(
placeholders
,
"?"
),
append
(
args
,
create
.
ID
)
create
.
IdentifierFilter
,
}
string
(
configBytes
),
)
stmt
:=
"INSERT INTO `idp` ("
+
strings
.
Join
(
fields
,
", "
)
+
") VALUES ("
+
strings
.
Join
(
placeholders
,
", "
)
+
")"
result
,
err
:=
d
.
db
.
ExecContext
(
ctx
,
stmt
,
args
...
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
store/db/sqlite/idp.go
View file @
c0619ef4
...
@@ -23,26 +23,16 @@ func (d *DB) CreateIdentityProvider(ctx context.Context, create *store.IdentityP
...
@@ -23,26 +23,16 @@ func (d *DB) CreateIdentityProvider(ctx context.Context, create *store.IdentityP
return
nil
,
errors
.
Errorf
(
"unsupported idp type %s"
,
string
(
create
.
Type
))
return
nil
,
errors
.
Errorf
(
"unsupported idp type %s"
,
string
(
create
.
Type
))
}
}
stmt
:=
`
placeholders
:=
[]
string
{
"?"
,
"?"
,
"?"
,
"?"
}
INSERT INTO idp (
fields
:=
[]
string
{
"`name`"
,
"`type`"
,
"`identifier_filter`"
,
"`config`"
}
name,
args
:=
[]
any
{
create
.
Name
,
create
.
Type
,
create
.
IdentifierFilter
,
string
(
configBytes
)}
type,
identifier_filter,
if
create
.
ID
!=
0
{
config
fields
,
placeholders
,
args
=
append
(
fields
,
"`id`"
),
append
(
placeholders
,
"?"
),
append
(
args
,
create
.
ID
)
)
}
VALUES (?, ?, ?, ?)
RETURNING id
stmt
:=
"INSERT INTO `idp` ("
+
strings
.
Join
(
fields
,
", "
)
+
") VALUES ("
+
strings
.
Join
(
placeholders
,
", "
)
+
") RETURNING `id`"
`
if
err
:=
d
.
db
.
QueryRowContext
(
ctx
,
stmt
,
args
...
)
.
Scan
(
&
create
.
ID
);
err
!=
nil
{
if
err
:=
d
.
db
.
QueryRowContext
(
ctx
,
stmt
,
create
.
Name
,
create
.
Type
,
create
.
IdentifierFilter
,
string
(
configBytes
),
)
.
Scan
(
&
create
.
ID
,
);
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment