From e95294d0444a72428ab561e1f6ed1a3e3aa3bacf Mon Sep 17 00:00:00 2001 From: Roland Bock Date: Thu, 15 Aug 2013 09:48:57 +0200 Subject: [PATCH] Some README typos --- README.md | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index b4b3f53c..5993deb2 100644 --- a/README.md +++ b/README.md @@ -10,15 +10,15 @@ SQL and C++ are both strongly typed languages. Still, most C/C++ interfaces to S sqlpp11 is a templated library representing an embedded domain specific language (EDSL) that allows you to - * define types representing tables and columns, - * construct type safe queries checked at compile time for syntax errors, type errors, name errors and even some semantic errors, - * interpret results by iterating over query-specific structs with appropriately named and typed members. + * define types representing tables and columns, + * construct type safe queries checked at compile time for syntax errors, type errors, name errors and even some semantic errors, + * interpret results by iterating over query-specific structs with appropriately named and typed members. This results in several benefits, e.g. - * the library user operates comfortably on structs and functions, - * the compiler reports many kinds of errors long before the code enters unit testing or production, - * the library hides the gory details of string construction for queries and interpreting string based results returned by select calls. + * the library user operates comfortably on structs and functions, + * the compiler reports many kinds of errors long before the code enters unit testing or production, + * the library hides the gory details of string construction for queries and interpreting string based results returned by select calls. Examples: --------- @@ -26,9 +26,9 @@ For the examples, lets assume you have a table class representing something like ```SQL CREATE TABLE foo ( - id bigint, - name varchar(50), - hasFun bool + id bigint, + name varchar(50), + hasFun bool ); ``` @@ -41,23 +41,23 @@ Db db(/* some arguments*/); // selecting zero or more results, iterating over the results for (const auto& row: db.run(select(foo.name, foo.hasFun).from(foo).where(foo.id > 17 and foo.name.like("%bar%")))) { - if (row.name.is_null()) - std::cerr << "name is null, will convert to empty string" << std::endl; - std::string name = row.name; // string-like fields are implicitly convertible to string - bool hasFun = hasFun; // bool fields are implicitly convertible to bool + if (row.name.is_null()) + std::cerr << "name is null, will convert to empty string" << std::endl; + std::string name = row.name; // string-like fields are implicitly convertible to string + bool hasFun = hasFun; // bool fields are implicitly convertible to bool } // selecting ALL columns of a table -for (const auto& row: db.run(select(all_of(foo)).from(foo).where(hasFun or foo.name == "joker"))) +for (const auto& row: db.run(select(all_of(foo)).from(foo).where(foo.hasFun or foo.name == "joker"))) { - int64_t id = row.id; // numeric fields are implicitly convertible to numeric c++ types + int64_t id = row.id; // numeric fields are implicitly convertible to numeric c++ types } // selecting zero or one row, showing off with an alias: SQLPP_ALIAS_PROVIDER_GENERATOR(cheese); if (const auto& row = db.run(select(foo.name.as(cheese)).from(foo).where(foo.id == 17))) { - std::cerr << "found: " << row.cheese << std::endl; + std::cerr << "found: " << row.cheese << std::endl; } // selecting exactly one row: @@ -73,7 +73,7 @@ db.run(insert_into(foo).set(foo.id = 17, foo.name = "bar", foo.hasFun = true)); db.run(update(foo).set(foo.hasFun = not foo.hasFun).where(foo.name != "nobody")); // A sample delete -db.run(remove_from(tab).where(not tab.hasFun)); +db.run(remove_from(foo).where(not foo.hasFun)); ``` Requirements: