mirror of
https://github.com/RGBCube/serenity
synced 2025-05-16 19:55:06 +00:00
LibSQL: Introduce SELECT ... LIMIT xxx OFFSET yyy
What it says on the tin.
This commit is contained in:
parent
7fc901d1b3
commit
6e9f06fc9f
5 changed files with 166 additions and 7 deletions
31
Userland/Libraries/LibSQL/SQLResult.cpp
Normal file
31
Userland/Libraries/LibSQL/SQLResult.cpp
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Jan de Visser <jan@de-visser.net>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibSQL/SQLResult.h>
|
||||
|
||||
namespace SQL {
|
||||
|
||||
void SQLResult::insert(Tuple const& row, Tuple const& sort_key)
|
||||
{
|
||||
m_has_results = true;
|
||||
m_result_set.insert_row(row, sort_key);
|
||||
}
|
||||
|
||||
void SQLResult::limit(size_t offset, size_t limit)
|
||||
{
|
||||
if (offset > 0) {
|
||||
if (offset > m_result_set.size()) {
|
||||
m_result_set.clear();
|
||||
return;
|
||||
}
|
||||
m_result_set.remove(0, offset);
|
||||
}
|
||||
if (m_result_set.size() > limit) {
|
||||
m_result_set.remove(limit, m_result_set.size() - limit);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue