summaryrefslogtreecommitdiff
path: root/slicer/db/sqlCommon.cpp
blob: 7ef00464b2766f8e8b41c3d3adca87d0738b7651 (plain)
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
56
57
58
59
60
61
62
63
64
65
66
67
#include "sqlCommon.h"
#include <compileTimeFormatter.h>
#include <metadata.h>
#include <sqlExceptions.h>

namespace Slicer {
	constexpr std::string_view md_pkey {"db:pkey"};
	constexpr std::string_view md_auto {"db:auto"};
	constexpr std::string_view md_ignore {"db:ignore"};
	constexpr std::string_view md_global_ignore {"ignore"};

	bool
	isPKey(const HookCommon * h)
	{
		return h->GetMetadata().flagSet(md_pkey) && isBind(h);
	}

	bool
	isAuto(const HookCommon * h)
	{
		return h->GetMetadata().flagSet(md_auto) && isBind(h);
	}

	bool
	isNotAuto(const HookCommon * h)
	{
		return h->GetMetadata().flagNotSet(md_auto) && isBind(h);
	}

	bool
	isBind(const HookCommon * h)
	{
		return h->GetMetadata().flagNotSet(md_global_ignore) && h->GetMetadata().flagNotSet(md_ignore);
	}

	bool
	isValue(const HookCommon * h)
	{
		return h->GetMetadata().flagNotSet(md_auto) && h->GetMetadata().flagNotSet(md_pkey) && isBind(h);
	}

	void
	TooManyRowsReturned::ice_print(std::ostream & s) const
	{
		s << "Too many rows returned";
	}

	void
	NoRowsReturned::ice_print(std::ostream & s) const
	{
		s << "No rows returned";
	}

	void
	NoRowsFound::ice_print(std::ostream & s) const
	{
		s << "No rows found";
	}

	AdHocFormatter(UnsuitableIdFieldTypeMsg, "Unsuitable id field type [%?]");
	void
	UnsuitableIdFieldType::ice_print(std::ostream & s) const
	{
		UnsuitableIdFieldTypeMsg::write(s, type);
	}

}