Пример #1
0
int main()
{
	test::TabFoo f; 
	test::TabBar t;

	sqlpp::select(t.alpha).flags(sqlpp::all).from(t);
	for (const auto& row : db(select(all_of(t)).from(t).where(true)))
	{
		int64_t a = row.alpha;
		const std::string b = row.beta;
		std::cout << a << ", " << b << std::endl;
	}

	for (const auto& row : db(select(all_of(t).as(t)).from(t).where(true)))
	{
		int64_t a = row.tabBar.alpha;
		const std::string b = row.tabBar.beta;
		std::cout << a << ", " << b << std::endl;
	}

	for (const auto& row : db(select(all_of(t).as(t), t.gamma).from(t).where(t.alpha > 7)))
	{
		int64_t a = row.tabBar.alpha;
		const std::string b = row.tabBar.beta;
		const bool g = row.gamma;
		std::cout << a << ", " << b << ", " << g << std::endl;
	}

	for (const auto& row : db(select(all_of(t), all_of(f)).from(t.join(f).on(t.alpha > f.omega and not t.gamma)).where(true)))
	{
		std::cout << row.alpha << std::endl;
	}

	auto stat = sqlpp::select().columns(all_of(t)).flags(sqlpp::all).from(t).extra_tables(f,t).where(t.alpha > 0).group_by(t.alpha).order_by(t.gamma.asc()).having(t.gamma).limit(7).offset(19);

	auto s = dynamic_select(db).dynamic_columns(all_of(t)).dynamic_flags().dynamic_from(t).extra_tables(f,t).dynamic_where().dynamic_group_by(t.alpha).dynamic_order_by().dynamic_having(t.gamma).dynamic_limit().dynamic_offset();
	s.select_flags.add(sqlpp::distinct);
	s.selected_columns.add(f.omega);
	s.from.add(f);
	s.where.add(t.alpha > 7);
	s.having.add(t.alpha > 7);
	s.limit.set(3);
	s.offset.set(3);
	s.group_by.add(t.beta);
	s.order_by.add(t.beta.asc());
	for (const auto& row : db(s))
	{
		int64_t a = row.alpha;
		std::cout << a << std::endl;
	}

	printer.reset();
	std::cerr << serialize(s, printer).str() << std::endl;
	printer.reset();
	std::cerr << serialize(stat, printer).str() << std::endl;

	select(sqlpp::value(7).as(t.alpha));

	return 0;
}
Пример #2
0
int select(int, char* [])
{
  static constexpr bool some_condition = true;
  static constexpr bool some_other_condition = false;

  MockDb db{};

  const auto p = test::TabPerson{};
#if 0
  const auto f = test::TabFeature{};
#endif

  for (const auto& row : db(select(all_of(p)).from(p).where(p.id > 7)))
  {
    int64_t id = row.id;
    std::string name = row.name;
    int64_t feature = row.feature;
  }

#if 0
	for (const auto& row : db(select(p.name).from(p).where(p.name.like("Herb%"))))
	{
		int64_t id = row.id;
		std::string name = row.name;
		int64_t feature = row.feature;
	}
#endif

#if 0
	for (const auto& row : db(select(p.name, f.name.as(cheesecake)).from(p,f).where(p.id > 7 and p.feature == 3)))
	{
		//int64_t id = row.id;
		//std::string a = row.a;
		std::string name = row.name;
		std::string feature = row.cheesecake;
	}
#endif

#if 0
	for (const auto& row : db(select(multi_column(all_of(p)).as(p), multi_column(f.name, f.id).as(f)).from(p,f).where(true)))
	{
		//int64_t id = row.id;
		//std::string a = row.a;
		std::string name = row.tabPerson.name;
		std::string name1 = row.tabFeature.name;
		//int64_t feature = row.feature;
	}
#endif

#if 0
	auto s = select(p.id, p.name, f.id.as(cheesecake))
				      .from(p, f)
						  .where(p.name == any(select(f.name)
										               .from(f)
																	 .where(true)))
							.group_by(f.name)
							.having(p.name.like("%Bee%"))
							.order_by(p.name.asc())
							.limit(3).offset(7);

	auto x = s.as(sqlpp::alias::x);
	for (const auto& row : db(select(p.id, p.name, all_of(x).as(x))
				.from(p.join(x).on(p.feature == x.cheesecake))
				.where(true)))
	{
		int64_t id = row.id;
		std::string name = row.name;
		std::string x_name = row.x.name;
		int cheesecake = row.x.cheesecake;
	}
#endif

#if !0
  auto dysel = dynamic_select(db).dynamic_columns(p.name).from(p).dynamic_where();

  if (some_condition)
    dysel.selected_columns.add(p.feature);

  if (some_other_condition)
    dysel.where.add(p.id > 17);

  for (const auto& row : db(dysel))
  {
    std::string name = row.name;
    std::string feature = row.at("feature");
  }
#endif

  return 0;
}
Пример #3
0
int Interpret(int, char* [])
{
  MockDb db = {};
  MockDb::_serializer_context_t printer = {};

  const auto f = test::TabFoo{};
  const auto t = test::TabBar{};
  select(t.alpha.as(t.beta));

  serialize(insert_into(t).columns(t.beta, t.gamma), printer).str();
  {
    auto i = insert_into(t).columns(t.gamma, t.beta);
    i.values.add(t.gamma = true, t.beta = "cheesecake");
    serialize(i, printer).str();
    i.values.add(t.gamma = false, t.beta = sqlpp::tvin("coffee"));
    i.values.add(t.gamma = false, t.beta = sqlpp::tvin(std::string()));
    serialize(i, printer).str();
    i.values.add(t.gamma = sqlpp::default_value, t.beta = sqlpp::null);
    serialize(i, printer).str();
  }

  serialize(t.alpha = sqlpp::null, printer).str();
  serialize(t.alpha = sqlpp::default_value, printer).str();
  serialize(t.alpha, printer).str();
  serialize(-t.alpha, printer).str();
  serialize(+t.alpha, printer).str();
  serialize(-(t.alpha + 7), printer).str();
  serialize(t.alpha = 0, printer).str();
  serialize(t.alpha = sqlpp::tvin(0), printer).str();
  serialize(t.alpha == 0, printer).str();
  serialize(t.alpha == sqlpp::tvin(0), printer).str();
  serialize(t.alpha != 0, printer).str();
  serialize(t.gamma != sqlpp::tvin(false), printer).str();
  serialize(t.alpha == 7, printer).str();
  serialize(t.delta = sqlpp::tvin(0), printer).str();
  serialize(t.beta + "kaesekuchen", printer).str();

  serialize(sqlpp::select(), printer).str();
  serialize(sqlpp::select().flags(sqlpp::distinct), printer).str();
  serialize(select(t.alpha, t.beta).flags(sqlpp::distinct), printer).str();
  serialize(select(t.alpha, t.beta), printer).str();
  serialize(select(t.alpha, t.beta).from(t), printer).str();
  serialize(select(t.alpha, t.beta).from(t).where(t.alpha == 3), printer).str();
  serialize(select(t.alpha, t.beta).from(t).where(t.alpha == 3).group_by(t.gamma), printer).str();
  serialize(select(t.alpha, t.beta).from(t).where(t.alpha == 3).group_by(t.gamma).having(t.beta.like("%kuchen")),
            printer).str();
  serialize(select(t.alpha, t.beta)
                .from(t)
                .where(t.alpha == 3)
                .group_by(t.gamma)
                .having(t.beta.like("%kuchen"))
                .order_by(t.beta.asc()),
            printer).str();
  serialize(select(t.alpha, t.beta)
                .from(t)
                .where(t.alpha == 3)
                .group_by(t.gamma)
                .having(t.beta.like("%kuchen"))
                .order_by(t.beta.asc())
                .limit(17)
                .offset(3),
            printer).str();

  serialize(parameter(sqlpp::bigint(), t.alpha), printer).str();
  serialize(parameter(t.alpha), printer).str();
  serialize(t.alpha == parameter(t.alpha), printer).str();
  serialize(t.alpha == parameter(t.alpha) and (t.beta + "gimmick").like(parameter(t.beta)), printer).str();

  serialize(insert_into(t), printer).str();
  serialize(insert_into(f).default_values(), printer).str();
  serialize(insert_into(t).set(t.gamma = true), printer).str();
  // serialize(insert_into(t).set(t.gamma = sqlpp::tvin(false)), printer).str(); cannot test this since gamma cannot be
  // null and a static assert is thrown

  serialize(update(t), printer).str();
  serialize(update(t).set(t.gamma = true), printer).str();
  serialize(update(t).set(t.gamma = true).where(t.beta.in("kaesekuchen", "cheesecake")), printer).str();
  serialize(update(t).set(t.gamma = true).where(t.beta.in()), printer).str();

  serialize(remove_from(t), printer).str();
  serialize(remove_from(t).using_(t), printer).str();
  serialize(remove_from(t).where(t.alpha == sqlpp::tvin(0)), printer).str();
  serialize(remove_from(t).using_(t).where(t.alpha == sqlpp::tvin(0)), printer).str();

  // functions
  serialize(sqlpp::value(7), printer).str();
  serialize(sqlpp::verbatim<sqlpp::integral>("irgendwas integrales"), printer).str();
  serialize(sqlpp::value_list(std::vector<int>({1, 2, 3, 4, 5, 6, 8})), printer).str();
  serialize(exists(select(t.alpha).from(t)), printer).str();
  serialize(any(select(t.alpha).from(t)), printer).str();
  serialize(some(select(t.alpha).from(t)), printer).str();
  serialize(count(t.alpha), printer).str();
  serialize(min(t.alpha), printer).str();
  serialize(max(t.alpha), printer).str();
  serialize(avg(t.alpha), printer).str();
  serialize(sum(t.alpha), printer).str();
  serialize(sqlpp::verbatim_table("whatever"), printer).str();

  // alias
  serialize(t.as(t.alpha), printer).str();
  serialize(t.as(t.alpha).beta, printer).str();

  // select alias
  serialize(select(t.alpha).from(t).where(t.beta > "kaesekuchen").as(t.gamma), printer).str();

  serialize(t.alpha.is_null(), printer).str();

  // join
  serialize(t.inner_join(t.as(t.alpha)).on(t.beta == t.as(t.alpha).beta), printer).str();
  {
    auto inner = t.inner_join(t.as(t.alpha)).on(t.beta == t.as(t.alpha).beta);
    serialize(select(t.alpha).from(inner), printer).str();
  }

  // multi_column
  serialize(multi_column(t.alpha, (t.beta + "cake").as(t.gamma)).as(t.alpha), printer).str();
  serialize(multi_column(all_of(t)).as(t), printer).str();
  serialize(all_of(t).as(t), printer).str();

  // dynamic select
  {
    auto s = dynamic_select(db).dynamic_flags().dynamic_columns().from(t);
    s.selected_columns.add(t.beta);
    s.selected_columns.add(t.gamma);
    serialize(s, printer).str();
  }
  {
    auto s = dynamic_select(db).dynamic_flags().dynamic_columns().from(t);
    s.select_flags.add(sqlpp::distinct);
    s.selected_columns.add(t.beta);
    s.selected_columns.add(t.gamma);
    serialize(s, printer).str();
  }
  {
    // Behold, dynamically constructed queries might compile but be illegal SQL
    auto s = dynamic_select(db).dynamic_flags(sqlpp::distinct).dynamic_columns(t.alpha);
    s.select_flags.add(sqlpp::all);
    s.selected_columns.add(without_table_check(t.beta));
    s.selected_columns.add(without_table_check(t.gamma));
    serialize(s, printer).str();
  }

  // distinct aggregate
  serialize(count(sqlpp::distinct, t.alpha % 7), printer).str();
  serialize(avg(sqlpp::distinct, t.alpha - 7), printer).str();
  serialize(sum(sqlpp::distinct, t.alpha + 7), printer).str();

  serialize(select(all_of(t)).from(t).unconditionally(), printer).str();

  for (const auto& row : db(select(all_of(t)).from(t).unconditionally()))
  {
    serialize(row.alpha, printer);
    serialize(row.beta, printer);
    serialize(row.gamma, printer);
  }

  get_sql_name(t);
  get_sql_name(t.alpha);

  flatten(t.alpha == 7, db);

  auto x = boolean_expression(db, t.alpha == 7);
  x = sqlpp::boolean_expression<MockDb>(t.beta.like("%cheesecake"));
  x = x and boolean_expression(db, t.gamma);
  std::cerr << "----------------------------" << std::endl;
  printer.reset();
  std::cerr << serialize(x, printer).str() << std::endl;

  printer.reset();
  std::cerr << serialize(select(all_of(t)).from(t).where(t.alpha.in(select(f.epsilon).from(f).unconditionally())),
                         printer).str() << std::endl;

  printer.reset();
  std::cerr << serialize(select(all_of(t)).from(t).where(t.alpha.in()), printer).str() << std::endl;

  printer.reset();
  std::cerr << serialize(select(all_of(t)).from(t).where(t.alpha.not_in()), printer).str() << std::endl;

  auto schema = db.attach("lorem");
  auto s = schema_qualified_table(schema, t).as(sqlpp::alias::x);

  printer.reset();
  std::cerr << serialize(select(all_of(s)).from(s).unconditionally(), printer).str() << std::endl;

  printer.reset();
  std::cerr << serialize(sqlpp::case_when(true).then(t.alpha).else_(t.alpha + 1).as(t.beta), printer).str()
            << std::endl;

  return 0;
}
Пример #4
0
int main()
{
	test::TabFoo f; 
	test::TabBar t;

	// Test a table
	{
		using T = decltype(t);
		static_assert(not sqlpp::is_numeric_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_integral_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_floating_point_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_expression_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_named_expression_t<T>::value, "type requirement");
		static_assert(not sqlpp::require_insert_t<T>::value, "type requirement");
		static_assert(not sqlpp::must_not_insert_t<T>::value, "type requirement");
		static_assert(not sqlpp::must_not_update_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_boolean_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_text_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_alias_t<T>::value, "type requirement");
		static_assert(sqlpp::is_table_t<T>::value, "type requirement");
		static_assert(sqlpp::is_regular<T>::value, "type requirement");
	}

	// Test an alias of table
	{
		using T = decltype(t.as(alias::a));
		static_assert(not sqlpp::is_numeric_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_integral_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_floating_point_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_expression_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_named_expression_t<T>::value, "type requirement");
		static_assert(not sqlpp::require_insert_t<T>::value, "type requirement");
		static_assert(not sqlpp::must_not_insert_t<T>::value, "type requirement");
		static_assert(not sqlpp::must_not_update_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_boolean_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_text_t<T>::value, "type requirement");
		static_assert(sqlpp::is_alias_t<T>::value, "type requirement");
		static_assert(sqlpp::is_table_t<T>::value, "type requirement");
		static_assert(sqlpp::is_regular<T>::value, "type requirement");
	}

	// Test an integral column of an alias of table
	{
		using T = decltype(t.as(alias::a).alpha);
		static_assert(sqlpp::is_numeric_t<T>::value, "type requirement");
		static_assert(sqlpp::is_integral_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_floating_point_t<T>::value, "type requirement");
		static_assert(sqlpp::is_expression_t<T>::value, "type requirement");
		static_assert(sqlpp::is_named_expression_t<T>::value, "type requirement");
		static_assert(not sqlpp::require_insert_t<T>::value, "type requirement");
		static_assert(sqlpp::must_not_insert_t<T>::value, "type requirement");
		static_assert(sqlpp::must_not_update_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_boolean_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_text_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_alias_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_table_t<T>::value, "type requirement");
		static_assert(sqlpp::is_regular<T>::value, "type requirement");
	}


	// Test an integral table column
	{
		using T = decltype(t.alpha);
		static_assert(sqlpp::is_numeric_t<T>::value, "type requirement");
		static_assert(sqlpp::is_integral_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_floating_point_t<T>::value, "type requirement");
		static_assert(sqlpp::is_expression_t<T>::value, "type requirement");
		static_assert(sqlpp::is_named_expression_t<T>::value, "type requirement");
		static_assert(not sqlpp::require_insert_t<T>::value, "type requirement");
		static_assert(sqlpp::must_not_insert_t<T>::value, "type requirement");
		static_assert(sqlpp::must_not_update_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_boolean_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_text_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_alias_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_table_t<T>::value, "type requirement");
		static_assert(sqlpp::is_regular<T>::value, "type requirement");
	}

	// Test a floating point table column
	{
		using T = decltype(f.omega);
		static_assert(sqlpp::is_numeric_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_integral_t<T>::value, "type requirement");
		static_assert(sqlpp::is_floating_point_t<T>::value, "type requirement");
		static_assert(sqlpp::is_expression_t<T>::value, "type requirement");
		static_assert(sqlpp::is_named_expression_t<T>::value, "type requirement");
		static_assert(not sqlpp::require_insert_t<T>::value, "type requirement");
		static_assert(not sqlpp::must_not_insert_t<T>::value, "type requirement");
		static_assert(not sqlpp::must_not_update_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_boolean_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_text_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_alias_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_table_t<T>::value, "type requirement");
		static_assert(sqlpp::is_regular<T>::value, "type requirement");
	}

	// Test a an alias of a numeric table column
	{
		using T = decltype(t.alpha.as(alias::a));
		static_assert(sqlpp::is_numeric_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_expression_t<T>::value, "type requirement");
		static_assert(sqlpp::is_named_expression_t<T>::value, "type requirement");
		static_assert(not sqlpp::require_insert_t<T>::value, "type requirement");
		static_assert(not sqlpp::must_not_insert_t<T>::value, "type requirement");
		static_assert(not sqlpp::must_not_update_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_boolean_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_text_t<T>::value, "type requirement");
		static_assert(sqlpp::is_alias_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_table_t<T>::value, "type requirement");
		static_assert(sqlpp::is_regular<T>::value, "type requirement");
	}

	// Test a select of a single column without a from
	{
		using T = decltype(select(t.alpha));
		static_assert(sqlpp::is_numeric_t<T>::value, "type requirement");
		static_assert(sqlpp::is_expression_t<T>::value, "type requirement");
		static_assert(sqlpp::is_named_expression_t<T>::value, "type requirement");
		static_assert(not sqlpp::require_insert_t<T>::value, "type requirement");
		static_assert(not sqlpp::must_not_insert_t<T>::value, "type requirement");
		static_assert(not sqlpp::must_not_update_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_boolean_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_text_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_alias_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_table_t<T>::value, "type requirement");
		static_assert(sqlpp::is_regular<T>::value, "type requirement");
	}

	// Test a select of a single numeric table column
	{
		using T = decltype(select(t.alpha).from(t));
		//static_assert(sqlpp::is_select_column_list_t<decltype(T::_column_list)>::value, "Must not be noop");
		//static_assert(sqlpp::is_from_t<decltype(T::_from)>::value, "Must not be noop");
		static_assert(sqlpp::is_numeric_t<T>::value, "type requirement");
		static_assert(sqlpp::is_expression_t<T>::value, "type requirement");
		static_assert(sqlpp::is_named_expression_t<T>::value, "type requirement");
		static_assert(not sqlpp::require_insert_t<T>::value, "type requirement");
		static_assert(not sqlpp::must_not_insert_t<T>::value, "type requirement");
		static_assert(not sqlpp::must_not_update_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_boolean_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_text_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_alias_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_table_t<T>::value, "type requirement");
		static_assert(sqlpp::is_regular<T>::value, "type requirement");
	}

	// Test a select of an alias of a single numeric table column
	{
		using T = decltype(select(t.alpha.as(alias::a)).from(t));
		static_assert(sqlpp::is_numeric_t<T>::value, "type requirement");
		static_assert(sqlpp::is_expression_t<T>::value, "type requirement");
		static_assert(sqlpp::is_named_expression_t<T>::value, "type requirement");
		static_assert(not sqlpp::require_insert_t<T>::value, "type requirement");
		static_assert(not sqlpp::must_not_insert_t<T>::value, "type requirement");
		static_assert(not sqlpp::must_not_update_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_boolean_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_text_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_alias_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_table_t<T>::value, "type requirement");
		static_assert(sqlpp::is_regular<T>::value, "type requirement");
	}

	// Test an alias of a select of a single numeric table column
	{
		using T = decltype(select(t.alpha).from(t).as(alias::b));
		static_assert(not sqlpp::is_numeric_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_expression_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_named_expression_t<T>::value, "type requirement");
		static_assert(not sqlpp::require_insert_t<T>::value, "type requirement");
		static_assert(not sqlpp::must_not_insert_t<T>::value, "type requirement");
		static_assert(not sqlpp::must_not_update_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_boolean_t<T>::value, "red to not be boolean");
		static_assert(not sqlpp::is_text_t<T>::value, "type requirement");
		static_assert(sqlpp::is_alias_t<T>::value, "type requirement");
		static_assert(sqlpp::is_table_t<T>::value, "type requirement");
		static_assert(sqlpp::is_regular<T>::value, "type requirement");
	}

	// Test the column of an alias of a select of an alias of a single numeric table column
	{
		using T = decltype(select(t.alpha.as(alias::a)).from(t).as(alias::b));
		static_assert(not sqlpp::is_numeric_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_expression_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_named_expression_t<T>::value, "type requirement");
		static_assert(not sqlpp::require_insert_t<T>::value, "type requirement");
		static_assert(not sqlpp::must_not_insert_t<T>::value, "type requirement");
		static_assert(not sqlpp::must_not_update_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_boolean_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_text_t<T>::value, "type requirement");
		static_assert(sqlpp::is_alias_t<T>::value, "type requirement");
		static_assert(sqlpp::is_table_t<T>::value, "type requirement");
		static_assert(sqlpp::is_regular<T>::value, "type requirement");
	}

	// Test the column of an alias of a select of a single numeric table column
	{
		using T = decltype(select(t.alpha).from(t).as(alias::b).alpha);
		static_assert(sqlpp::is_numeric_t<T>::value, "type requirement");
		static_assert(sqlpp::is_expression_t<T>::value, "type requirement");
		static_assert(sqlpp::is_named_expression_t<T>::value, "type requirement");
		static_assert(not sqlpp::require_insert_t<T>::value, "type requirement");
		static_assert(sqlpp::must_not_insert_t<T>::value, "type requirement");
		static_assert(sqlpp::must_not_update_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_boolean_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_text_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_alias_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_table_t<T>::value, "type requirement");
		static_assert(sqlpp::is_regular<T>::value, "type requirement");
	}

	// Test an alias of a select of an alias of a single numeric table column
	{
		using T = decltype(select(t.alpha.as(alias::a)).from(t).as(alias::b).a);
		static_assert(sqlpp::is_numeric_t<T>::value, "type requirement");
		static_assert(sqlpp::is_expression_t<T>::value, "type requirement");
		static_assert(sqlpp::is_named_expression_t<T>::value, "type requirement");
		static_assert(not sqlpp::require_insert_t<T>::value, "type requirement");
		static_assert(sqlpp::must_not_insert_t<T>::value, "type requirement");
		static_assert(sqlpp::must_not_update_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_boolean_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_text_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_alias_t<T>::value, "type requirement");
		static_assert(not sqlpp::is_table_t<T>::value, "type requirement");
		static_assert(sqlpp::is_regular<T>::value, "type requirement");
	}

	// Test that all_of(tab) is expanded in select
	{
		auto a = select(all_of(t));
		auto b = select(t.alpha, t.beta, t.gamma, t.delta);
		//auto c = select(t);
		static_assert(std::is_same<decltype(a), decltype(b)>::value, "all_of(t) has to be expanded by select()");
		//static_assert(std::is_same<decltype(b), decltype(c)>::value, "t has to be expanded by select()");
	}

	// Test that all_of(tab) is expanded in multi_column
	{
		auto a = multi_column(all_of(t)).as(alias::a);
		auto b = multi_column(t.alpha, t.beta, t.gamma, t.delta).as(alias::a);
		static_assert(std::is_same<decltype(a), decltype(b)>::value, "all_of(t) has to be expanded by multi_column");
	}

	// Test that a multicolumn is not a value
	{
		auto m = multi_column(t.alpha, t.beta).as(alias::a);
		static_assert(not sqlpp::is_expression_t<decltype(m)>::value, "a multi_column is not a value");
	}

	// Test result field indices
	{
		using Select = decltype(select(
					all_of(t), // index 0, 1, 2, 3 (alpha, beta, gamma, delta)
					multi_column(all_of(t)).as(alias::left), // index 4 (including 4, 5, 6, 7)
					multi_column(all_of(t)).as(alias::right), // index 8 (including 8, 9, 10, 11)
					t.alpha.as(alias::a) // index 12
					).from(t).where(true)); // next index is 13
		using ResultRow = typename Select::_result_methods_t::template _result_row_t<MockDb>;
		using IndexSequence = ResultRow::_field_index_sequence;
		static_assert(std::is_same<IndexSequence, sqlpp::detail::field_index_sequence<13, 0, 1, 2, 3, 4, 8, 12>>::value, "invalid field sequence");
	}

	// Test that result sets with identical name/value combinations have identical types
	{
		auto a = select(t.alpha);
		auto b = select(f.epsilon.as(t.alpha));
		using A = typename decltype(a)::_result_row_t<MockDb>;
		using B = typename decltype(b)::_result_row_t<MockDb>;
		static_assert(std::is_same<
				sqlpp::value_type_of<decltype(t.alpha)>, 
				sqlpp::value_type_of<decltype(f.epsilon)>>::value, "Two bigint columns must have identical base_value_type");
		static_assert(std::is_same<A, B>::value, "select with identical columns(name/value_type) need to have identical result_types");
	}

	for (const auto& row : db(select(all_of(t)).from(t).where(true)))
	{
		int64_t a = row.alpha;
		std::cout << a << std::endl;
	}

	{
		auto s = dynamic_select(db, all_of(t)).dynamic_from().dynamic_where().dynamic_limit().dynamic_offset();
		s.from.add(t);
		s.where.add_ntc(t.alpha > 7 and t.alpha == any(select(t.alpha).from(t).where(t.alpha < 3)));
		s.limit.set(30);
		s.limit.set(3);
		std::cerr << "------------------------\n";
		serialize(s, printer).str();
		std::cerr << "------------------------\n";
		using T = decltype(s);
		static_assert(sqlpp::is_regular<T>::value, "type requirement");
	}

	// Test that select can be called with zero columns if it is used with dynamic columns.
	{
		auto s = dynamic_select(db).dynamic_columns().extra_tables(t);
		s.selected_columns.add(t.alpha);
		serialize(s, printer).str();
	}

	// Test that verbatim_table compiles
	{
		auto s = select(t.alpha).from(sqlpp::verbatim_table("my_unknown_table"));
		serialize(s, printer).str();
	}


	static_assert(sqlpp::is_select_flag_t<decltype(sqlpp::all)>::value, "sqlpp::all has to be a select_flag");
  using T = sqlpp::wrap_operand<int>::type;
	static_assert(sqlpp::is_regular<T>::value, "type requirement");
	static_assert(sqlpp::is_expression_t<T>::value, "T has to be an expression");
	static_assert(sqlpp::is_numeric_t<T>::value, "T has to be numeric");
	static_assert(sqlpp::is_numeric_t<decltype(t.alpha)>::value, "TabBar.alpha has to be a numeric");
	((t.alpha + 7) + 4).asc();
	static_assert(sqlpp::is_boolean_t<decltype(t.gamma == t.gamma)>::value, "Comparison expression have to be boolean");
	!t.gamma;
	t.beta < "kaesekuchen";
	serialize(t.beta + "hallenhalma", printer).str();
	static_assert(sqlpp::must_not_insert_t<decltype(t.alpha)>::value, "alpha must not be inserted");
	serialize(t.alpha, printer).str();
	std::cerr << "\n" << sizeof(test::TabBar) << std::endl;
	static_assert(sqlpp::is_named_expression_t<decltype(t.alpha)>::value, "alpha should be a named expression");
	static_assert(sqlpp::is_named_expression_t<decltype(t.alpha.as(alias::a))>::value, "an alias of alpha should be a named expression");
	static_assert(sqlpp::is_alias_t<decltype(t.alpha.as(alias::a))>::value, "an alias of alpha should be an alias");

	auto l = t.as(alias::left);
	auto r = select(t.gamma.as(alias::a)).from(t).where(t.gamma == true).as(alias::right);
	static_assert(sqlpp::is_boolean_t<decltype(select(t.gamma).from(t))>::value, "select(bool) has to be a bool");
	static_assert(sqlpp::is_boolean_t<decltype(select(r.a).from(r))>::value, "select(bool) has to be a bool");
	auto s1 = sqlpp::select().flags(sqlpp::distinct, sqlpp::straight_join).columns(l.alpha, l.beta, select(r.a).from(r))
		.from(r,t,l)
		.where(t.beta == "hello world" and select(t.gamma).from(t))// .as(alias::right))
		.group_by(l.gamma, r.a)
		.having(r.a != true)
		.order_by(l.beta.asc())
		.limit(17)
		.offset(3)
		.as(alias::a)
		;

	return 0;
}