mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 12:47:45 +00:00
AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null state), and while it's going to use UTF-8, the name UTF8String is a mouthful - so let's free up the String name by renaming the existing class. Making the old one have an annoying name will hopefully also help with quick adoption :^)
This commit is contained in:
parent
f74251606d
commit
6e19ab2bbc
2006 changed files with 11635 additions and 11636 deletions
|
@ -7,9 +7,9 @@
|
|||
|
||||
#include <LibTest/TestCase.h>
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/Result.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <AK/TypeCasts.h>
|
||||
|
@ -31,7 +31,7 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
using ParseResult = AK::Result<NonnullRefPtr<SQL::AST::Expression>, String>;
|
||||
using ParseResult = AK::Result<NonnullRefPtr<SQL::AST::Expression>, DeprecatedString>;
|
||||
|
||||
ParseResult parse(StringView sql)
|
||||
{
|
||||
|
@ -633,7 +633,7 @@ TEST_CASE(in_selection_expression)
|
|||
|
||||
TEST_CASE(expression_tree_depth_limit)
|
||||
{
|
||||
auto too_deep_expression = String::formatted("{:+^{}}1", "", SQL::AST::Limits::maximum_expression_tree_depth);
|
||||
auto too_deep_expression = DeprecatedString::formatted("{:+^{}}1", "", SQL::AST::Limits::maximum_expression_tree_depth);
|
||||
EXPECT(!parse(too_deep_expression.substring_view(1)).is_error());
|
||||
EXPECT(parse(too_deep_expression).is_error());
|
||||
}
|
||||
|
|
|
@ -148,7 +148,7 @@ void insert_and_get_to_and_from_hash_index(int num_keys)
|
|||
for (auto ix = 0; ix < num_keys; ix++) {
|
||||
SQL::Key k(hash_index->descriptor());
|
||||
k[0] = keys[ix];
|
||||
k[1] = String::formatted("The key value is {} and the pointer is {}", keys[ix], pointers[ix]);
|
||||
k[1] = DeprecatedString::formatted("The key value is {} and the pointer is {}", keys[ix], pointers[ix]);
|
||||
k.set_pointer(pointers[ix]);
|
||||
hash_index->insert(k);
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ void insert_and_get_to_and_from_hash_index(int num_keys)
|
|||
for (auto ix = 0; ix < num_keys; ix++) {
|
||||
SQL::Key k(hash_index->descriptor());
|
||||
k[0] = keys[ix];
|
||||
k[1] = String::formatted("The key value is {} and the pointer is {}", keys[ix], pointers[ix]);
|
||||
k[1] = DeprecatedString::formatted("The key value is {} and the pointer is {}", keys[ix], pointers[ix]);
|
||||
auto pointer_opt = hash_index->get(k);
|
||||
VERIFY(pointer_opt.has_value());
|
||||
EXPECT_EQ(pointer_opt.value(), pointers[ix]);
|
||||
|
@ -246,7 +246,7 @@ void insert_into_and_scan_hash_index(int num_keys)
|
|||
for (auto ix = 0; ix < num_keys; ix++) {
|
||||
SQL::Key k(hash_index->descriptor());
|
||||
k[0] = keys[ix];
|
||||
k[1] = String::formatted("The key value is {} and the pointer is {}", keys[ix], pointers[ix]);
|
||||
k[1] = DeprecatedString::formatted("The key value is {} and the pointer is {}", keys[ix], pointers[ix]);
|
||||
k.set_pointer(pointers[ix]);
|
||||
hash_index->insert(k);
|
||||
}
|
||||
|
@ -275,7 +275,7 @@ void insert_into_and_scan_hash_index(int num_keys)
|
|||
if (keys[ix] == key_value) {
|
||||
EXPECT_EQ(key.pointer(), pointers[ix]);
|
||||
if (found[ix])
|
||||
FAIL(String::formatted("Key {}, index {} already found previously", *key_value, ix));
|
||||
FAIL(DeprecatedString::formatted("Key {}, index {} already found previously", *key_value, ix));
|
||||
found[ix] = true;
|
||||
break;
|
||||
}
|
||||
|
@ -288,7 +288,7 @@ void insert_into_and_scan_hash_index(int num_keys)
|
|||
EXPECT_EQ(count, num_keys);
|
||||
for (auto ix = 0; ix < num_keys; ix++) {
|
||||
if (!found[ix])
|
||||
FAIL(String::formatted("Key {}, index {} not found", keys[ix], ix));
|
||||
FAIL(DeprecatedString::formatted("Key {}, index {} not found", keys[ix], ix));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace {
|
|||
|
||||
constexpr char const* db_name = "/tmp/test.db";
|
||||
|
||||
SQL::ResultOr<SQL::ResultSet> try_execute(NonnullRefPtr<SQL::Database> database, String const& sql)
|
||||
SQL::ResultOr<SQL::ResultSet> try_execute(NonnullRefPtr<SQL::Database> database, DeprecatedString const& sql)
|
||||
{
|
||||
auto parser = SQL::AST::Parser(SQL::AST::Lexer(sql));
|
||||
auto statement = parser.next_statement();
|
||||
|
@ -31,7 +31,7 @@ SQL::ResultOr<SQL::ResultSet> try_execute(NonnullRefPtr<SQL::Database> database,
|
|||
return statement->execute(move(database));
|
||||
}
|
||||
|
||||
SQL::ResultSet execute(NonnullRefPtr<SQL::Database> database, String const& sql)
|
||||
SQL::ResultSet execute(NonnullRefPtr<SQL::Database> database, DeprecatedString const& sql)
|
||||
{
|
||||
auto result = try_execute(move(database), sql);
|
||||
if (result.is_error()) {
|
||||
|
@ -531,7 +531,7 @@ TEST_CASE(select_with_limit)
|
|||
create_table(database);
|
||||
for (auto count = 0; count < 100; count++) {
|
||||
auto result = execute(database,
|
||||
String::formatted("INSERT INTO TestSchema.TestTable ( TextColumn, IntColumn ) VALUES ( 'Test_{}', {} );", count, count));
|
||||
DeprecatedString::formatted("INSERT INTO TestSchema.TestTable ( TextColumn, IntColumn ) VALUES ( 'Test_{}', {} );", count, count));
|
||||
EXPECT(result.size() == 1);
|
||||
}
|
||||
auto result = execute(database, "SELECT TextColumn, IntColumn FROM TestSchema.TestTable LIMIT 10;");
|
||||
|
@ -547,7 +547,7 @@ TEST_CASE(select_with_limit_and_offset)
|
|||
create_table(database);
|
||||
for (auto count = 0; count < 100; count++) {
|
||||
auto result = execute(database,
|
||||
String::formatted("INSERT INTO TestSchema.TestTable ( TextColumn, IntColumn ) VALUES ( 'Test_{}', {} );", count, count));
|
||||
DeprecatedString::formatted("INSERT INTO TestSchema.TestTable ( TextColumn, IntColumn ) VALUES ( 'Test_{}', {} );", count, count));
|
||||
EXPECT(result.size() == 1);
|
||||
}
|
||||
auto result = execute(database, "SELECT TextColumn, IntColumn FROM TestSchema.TestTable LIMIT 10 OFFSET 10;");
|
||||
|
@ -562,7 +562,7 @@ TEST_CASE(select_with_order_limit_and_offset)
|
|||
create_table(database);
|
||||
for (auto count = 0; count < 100; count++) {
|
||||
auto result = execute(database,
|
||||
String::formatted("INSERT INTO TestSchema.TestTable ( TextColumn, IntColumn ) VALUES ( 'Test_{}', {} );", count, count));
|
||||
DeprecatedString::formatted("INSERT INTO TestSchema.TestTable ( TextColumn, IntColumn ) VALUES ( 'Test_{}', {} );", count, count));
|
||||
EXPECT(result.size() == 1);
|
||||
}
|
||||
auto result = execute(database, "SELECT TextColumn, IntColumn FROM TestSchema.TestTable ORDER BY IntColumn LIMIT 10 OFFSET 10;");
|
||||
|
@ -587,7 +587,7 @@ TEST_CASE(select_with_limit_out_of_bounds)
|
|||
create_table(database);
|
||||
for (auto count = 0; count < 100; count++) {
|
||||
auto result = execute(database,
|
||||
String::formatted("INSERT INTO TestSchema.TestTable ( TextColumn, IntColumn ) VALUES ( 'Test_{}', {} );", count, count));
|
||||
DeprecatedString::formatted("INSERT INTO TestSchema.TestTable ( TextColumn, IntColumn ) VALUES ( 'Test_{}', {} );", count, count));
|
||||
EXPECT(result.size() == 1);
|
||||
}
|
||||
auto result = execute(database, "SELECT TextColumn, IntColumn FROM TestSchema.TestTable LIMIT 500;");
|
||||
|
@ -602,7 +602,7 @@ TEST_CASE(select_with_offset_out_of_bounds)
|
|||
create_table(database);
|
||||
for (auto count = 0; count < 100; count++) {
|
||||
auto result = execute(database,
|
||||
String::formatted("INSERT INTO TestSchema.TestTable ( TextColumn, IntColumn ) VALUES ( 'Test_{}', {} );", count, count));
|
||||
DeprecatedString::formatted("INSERT INTO TestSchema.TestTable ( TextColumn, IntColumn ) VALUES ( 'Test_{}', {} );", count, count));
|
||||
EXPECT(result.size() == 1);
|
||||
}
|
||||
auto result = execute(database, "SELECT TextColumn, IntColumn FROM TestSchema.TestTable LIMIT 10 OFFSET 200;");
|
||||
|
@ -633,7 +633,7 @@ TEST_CASE(binary_operator_execution)
|
|||
create_table(database);
|
||||
|
||||
for (auto count = 0; count < 10; ++count) {
|
||||
auto result = execute(database, String::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count));
|
||||
auto result = execute(database, DeprecatedString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count));
|
||||
EXPECT_EQ(result.size(), 1u);
|
||||
}
|
||||
|
||||
|
@ -707,7 +707,7 @@ TEST_CASE(binary_operator_failure)
|
|||
create_table(database);
|
||||
|
||||
for (auto count = 0; count < 10; ++count) {
|
||||
auto result = execute(database, String::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count));
|
||||
auto result = execute(database, DeprecatedString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count));
|
||||
EXPECT_EQ(result.size(), 1u);
|
||||
}
|
||||
|
||||
|
@ -717,7 +717,7 @@ TEST_CASE(binary_operator_failure)
|
|||
auto error = result.release_error();
|
||||
EXPECT_EQ(error.error(), SQL::SQLErrorCode::NumericOperatorTypeMismatch);
|
||||
|
||||
auto message = String::formatted("NumericOperatorTypeMismatch: Cannot apply '{}' operator to non-numeric operands", op);
|
||||
auto message = DeprecatedString::formatted("NumericOperatorTypeMismatch: Cannot apply '{}' operator to non-numeric operands", op);
|
||||
EXPECT_EQ(error.error_string(), message);
|
||||
};
|
||||
|
||||
|
@ -777,7 +777,7 @@ TEST_CASE(delete_single_row)
|
|||
|
||||
create_table(database);
|
||||
for (auto count = 0; count < 10; ++count) {
|
||||
auto result = execute(database, String::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count));
|
||||
auto result = execute(database, DeprecatedString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count));
|
||||
EXPECT_EQ(result.size(), 1u);
|
||||
}
|
||||
|
||||
|
@ -821,7 +821,7 @@ TEST_CASE(delete_multiple_rows)
|
|||
|
||||
create_table(database);
|
||||
for (auto count = 0; count < 10; ++count) {
|
||||
auto result = execute(database, String::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count));
|
||||
auto result = execute(database, DeprecatedString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count));
|
||||
EXPECT_EQ(result.size(), 1u);
|
||||
}
|
||||
|
||||
|
@ -861,7 +861,7 @@ TEST_CASE(delete_all_rows)
|
|||
|
||||
create_table(database);
|
||||
for (auto count = 0; count < 10; ++count) {
|
||||
auto result = execute(database, String::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count));
|
||||
auto result = execute(database, DeprecatedString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count));
|
||||
EXPECT_EQ(result.size(), 1u);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
|
||||
#include <LibTest/TestCase.h>
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/Result.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <AK/TypeCasts.h>
|
||||
#include <AK/Vector.h>
|
||||
|
@ -19,7 +19,7 @@
|
|||
|
||||
namespace {
|
||||
|
||||
using ParseResult = AK::Result<NonnullRefPtr<SQL::AST::Statement>, String>;
|
||||
using ParseResult = AK::Result<NonnullRefPtr<SQL::AST::Statement>, DeprecatedString>;
|
||||
|
||||
ParseResult parse(StringView sql)
|
||||
{
|
||||
|
@ -392,7 +392,7 @@ TEST_CASE(update)
|
|||
EXPECT(parse("UPDATE OR table_name SET column_name=4;"sv).is_error());
|
||||
EXPECT(parse("UPDATE OR foo table_name SET column_name=4;"sv).is_error());
|
||||
|
||||
auto validate = [](StringView sql, SQL::AST::ConflictResolution expected_conflict_resolution, StringView expected_schema, StringView expected_table, StringView expected_alias, Vector<Vector<String>> expected_update_columns, bool expect_where_clause, bool expect_returning_clause, Vector<StringView> expected_returned_column_aliases) {
|
||||
auto validate = [](StringView sql, SQL::AST::ConflictResolution expected_conflict_resolution, StringView expected_schema, StringView expected_table, StringView expected_alias, Vector<Vector<DeprecatedString>> expected_update_columns, bool expect_where_clause, bool expect_returning_clause, Vector<StringView> expected_returned_column_aliases) {
|
||||
auto result = parse(sql);
|
||||
EXPECT(!result.is_error());
|
||||
|
||||
|
@ -439,7 +439,7 @@ TEST_CASE(update)
|
|||
}
|
||||
};
|
||||
|
||||
Vector<Vector<String>> update_columns { { "COLUMN_NAME" } };
|
||||
Vector<Vector<DeprecatedString>> update_columns { { "COLUMN_NAME" } };
|
||||
validate("UPDATE OR ABORT table_name SET column_name=1;"sv, SQL::AST::ConflictResolution::Abort, {}, "TABLE_NAME"sv, {}, update_columns, false, false, {});
|
||||
validate("UPDATE OR FAIL table_name SET column_name=1;"sv, SQL::AST::ConflictResolution::Fail, {}, "TABLE_NAME"sv, {}, update_columns, false, false, {});
|
||||
validate("UPDATE OR IGNORE table_name SET column_name=1;"sv, SQL::AST::ConflictResolution::Ignore, {}, "TABLE_NAME"sv, {}, update_columns, false, false, {});
|
||||
|
@ -567,7 +567,7 @@ TEST_CASE(select)
|
|||
};
|
||||
|
||||
struct Ordering {
|
||||
String collation_name;
|
||||
DeprecatedString collation_name;
|
||||
SQL::Order order;
|
||||
SQL::Nulls nulls;
|
||||
};
|
||||
|
@ -747,9 +747,9 @@ TEST_CASE(common_table_expression)
|
|||
|
||||
TEST_CASE(nested_subquery_limit)
|
||||
{
|
||||
auto subquery = String::formatted("{:(^{}}table_name{:)^{}}", "", SQL::AST::Limits::maximum_subquery_depth - 1, "", SQL::AST::Limits::maximum_subquery_depth - 1);
|
||||
EXPECT(!parse(String::formatted("SELECT * FROM {};"sv, subquery)).is_error());
|
||||
EXPECT(parse(String::formatted("SELECT * FROM ({});"sv, subquery)).is_error());
|
||||
auto subquery = DeprecatedString::formatted("{:(^{}}table_name{:)^{}}", "", SQL::AST::Limits::maximum_subquery_depth - 1, "", SQL::AST::Limits::maximum_subquery_depth - 1);
|
||||
EXPECT(!parse(DeprecatedString::formatted("SELECT * FROM {};"sv, subquery)).is_error());
|
||||
EXPECT(parse(DeprecatedString::formatted("SELECT * FROM ({});"sv, subquery)).is_error());
|
||||
}
|
||||
|
||||
TEST_CASE(describe_table)
|
||||
|
|
|
@ -47,11 +47,11 @@ TEST_CASE(text_value)
|
|||
EXPECT_EQ(v.to_string(), "Test"sv);
|
||||
}
|
||||
{
|
||||
SQL::Value v(String("String Test"sv));
|
||||
SQL::Value v(DeprecatedString("String Test"sv));
|
||||
EXPECT_EQ(v.type(), SQL::SQLType::Text);
|
||||
EXPECT_EQ(v.to_string(), "String Test"sv);
|
||||
|
||||
v = String("String Test 2"sv);
|
||||
v = DeprecatedString("String Test 2"sv);
|
||||
EXPECT_EQ(v.type(), SQL::SQLType::Text);
|
||||
EXPECT_EQ(v.to_string(), "String Test 2"sv);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue