FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
qsqlbuilder/sqlbuilder/Updater.cpp at master · MasterAler/qsqlbuilder · GitHub
MasterAler
/
qsqlbuilder
Public
Notifications
You must be signed in to change notification settings
Fork
5
Star
21
Code
Issues
1
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
qsqlbuilder
/
sqlbuilder
/
Updater.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
55 lines (42 loc) · 1.38 KB
Breadcrumbs
qsqlbuilder
/
sqlbuilder
/
Updater.cpp
Copy path
File metadata and controls
55 lines (42 loc) · 1.38 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#
include
"
Updater.h
"
#
include
"
Query.h
"
#
include
<
QSqlQuery
>
struct
Updater
::UpdaterPrivate
{
UpdaterPrivate
(
const
Query* q,
const
QVariantMap& updateValues)
: m_query(q)
, m_updateValues(updateValues)
{}
const
Query* m_query;
const
QVariantMap m_updateValues;
QString m_where;
};
const
QString Updater::
UPDATE_SQL
{
"
UPDATE %1 SET %2 WHERE %3
"
};
/*
*************************************************************************************
*/
Updater::Updater
(
const
Query* q,
const
QVariantMap& updateValues)
: impl(
new
UpdaterPrivate(q, updateValues))
{ }
Updater::~Updater
()
{ }
Updater::Updater
(Updater &&) = default;
Updater
Updater::where
(
OP
::Clause&& clause) &&
{
impl->
m_where
=
std::move
(clause).
getSQl
();
return
std::move
(*
this
);
}
bool
Updater::perform
() &&
{
QStringList setPart;
for
(
const
QString& key : impl->
m_updateValues
.
keys
())
{
setPart <<
QString
(
"
\"
%1
\"
=%2
"
)
.
arg
(key)
.
arg
(
OP::Clause::escapeValue
(impl->
m_updateValues
[key]));
}
const
QString sql = Updater::
UPDATE_SQL
.
arg
(impl->
m_query
->
tableName
())
.
arg
(setPart.
join
(
'
,
'
))
.
arg
(impl->
m_where
.
isEmpty
() ?
"
True
"
: impl->
m_where
);
QSqlQuery q = impl->
m_query
->
performSQL
(sql);
return
q.
numRowsAffected
() >
0
;
}
Back
|
FazBrowse Home
|
New Git URL