Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
website
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Show more breadcrumbs
Video AG Infrastruktur
website
Commits
ac621026
Commit
ac621026
authored
8 years ago
by
Julian Rother
Browse files
Options
Downloads
Patches
Plain Diff
Improved new-endpoint so it can create rows with NOT NULL-columns
parent
c54c4ac8
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
server.py
+14
-6
14 additions, 6 deletions
server.py
with
14 additions
and
6 deletions
server.py
+
14
−
6
View file @
ac621026
...
@@ -275,11 +275,9 @@ def edit(prefix='', ignore=[]):
...
@@ -275,11 +275,9 @@ def edit(prefix='', ignore=[]):
if
not
prefix
and
'
prefix
'
in
request
.
args
:
if
not
prefix
and
'
prefix
'
in
request
.
args
:
prefix
=
request
.
args
[
'
prefix
'
]
prefix
=
request
.
args
[
'
prefix
'
]
modify
(
'
BEGIN
'
)
modify
(
'
BEGIN
'
)
changes
=
request
.
values
.
items
()
if
request
.
is_json
:
if
request
.
is_json
:
changes
=
request
.
get_json
().
items
()
changes
=
request
.
get_json
().
items
()
else
:
changes
=
request
.
args
.
items
()
created
=
{}
for
key
,
val
in
changes
:
for
key
,
val
in
changes
:
if
key
in
ignore
:
if
key
in
ignore
:
continue
continue
...
@@ -299,9 +297,19 @@ def edit(prefix='', ignore=[]):
...
@@ -299,9 +297,19 @@ def edit(prefix='', ignore=[]):
@mod_required
@mod_required
def
create
(
table
):
def
create
(
table
):
assert
table
in
tabs
assert
table
in
tabs
id
=
modify
(
'
INSERT INTO %s (created_by, time_created, time_updated) VALUES (?, ?, ?)
'
%
tabs
[
table
][
0
],
columns
=
[
'
created_by
'
,
'
time_created
'
,
'
time_updated
'
]
session
[
'
user
'
][
'
dbid
'
],
datetime
.
now
(),
datetime
.
now
())
values
=
[
session
[
'
user
'
][
'
dbid
'
],
datetime
.
now
(),
datetime
.
now
()]
edit
(
prefix
=
table
+
'
.
'
+
str
(
id
)
+
'
.
'
)
args
=
request
.
values
if
request
.
is_json
:
args
=
request
.
get_json
()
for
column
,
val
in
args
.
items
():
if
column
==
'
ref
'
:
continue
assert
column
in
tabs
[
table
][
2
]
columns
.
append
(
column
)
values
.
append
(
val
)
id
=
modify
(
'
INSERT INTO %s (%s) VALUES (%s)
'
%
(
tabs
[
table
][
0
],
'
,
'
.
join
(
columns
),
'
,
'
.
join
([
'
?
'
]
*
len
(
values
))),
*
values
)
if
'
ref
'
in
request
.
values
:
if
'
ref
'
in
request
.
values
:
return
redirect
(
request
.
values
[
'
ref
'
])
return
redirect
(
request
.
values
[
'
ref
'
])
return
str
(
id
),
200
return
str
(
id
),
200
...
...
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