Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
NpgsqlRest/plugins/NpgsqlRest.CrudSource/CrudSourceQuery.cs at master · rchcomm/NpgsqlRest · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
View all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
rchcomm
/
NpgsqlRest
Public
forked from
NpgsqlRest/NpgsqlRest
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Files
Expand file tree
master
Breadcrumbs
NpgsqlRest
/
plugins
/
NpgsqlRest.CrudSource
/
CrudSourceQuery.cs
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
104 lines (97 loc) · 3.73 KB
master
Breadcrumbs
NpgsqlRest
/
plugins
/
NpgsqlRest.CrudSource
/
CrudSourceQuery.cs
Copy path
Top
File metadata and controls
Code
Blame
104 lines (97 loc) · 3.73 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
namespace
NpgsqlRest
.
CrudSource
;
internal
class
CrudSourceQuery
{
public
const
string
Query
=
"""
with _cte1 as (
select
nspname as schema
from
pg_catalog.pg_namespace
where
nspname not like 'pg_%'
and nspname <> 'information_schema'
and ($1 is null or nspname similar to $1)
and ($2 is null or nspname not similar to $2)
and ($3 is null or nspname = any($3))
and ($4 is null or not nspname = any($4))
), _cte2 as (
select
tc.table_name,
tc.table_schema,
coalesce(array_agg(kcu.column_name), '{}'::text[]) as primary_keys
from information_schema.table_constraints as tc
join information_schema.key_column_usage as kcu on tc.constraint_name = kcu.constraint_name and tc.table_schema = kcu.table_schema
join _cte1 on tc.table_schema = _cte1.schema
where
tc.constraint_type = 'PRIMARY KEY'
and ($5 is null or tc.table_name similar to $5)
and ($6 is null or tc.table_name not similar to $6)
and ($7 is null or tc.table_name = any($7))
and ($8 is null or not tc.table_name = any($8))
group by
tc.table_name,
tc.table_schema
)
select
t.table_type as type,
quote_ident(t.table_schema) as schema,
quote_ident(t.table_name) as name,
t.is_insertable_into = 'YES' as is_insertable,
count(*)::int as column_count,
coalesce(
array_agg(c.column_name order by c.ordinal_position),
'{}'::text[]
) as column_names,
coalesce(
array_agg(
case when c.data_type = 'bit' then 'varbit' else (c.udt_schema || '.' || c.udt_name)::regtype::text end
order by c.ordinal_position
),
'{}'::text[]
) as column_types,
coalesce(
array_agg(c.is_updatable = 'YES' order by c.ordinal_position),
'{}'::boolean[]
) as updatable_columns,
coalesce(
array_agg(coalesce(c.identity_generation, '') = 'ALWAYS' order by c.ordinal_position),
'{}'::boolean[]
) as identity_columns,
coalesce(
array_agg(
(
c.is_nullable = 'YES'
or c.column_default is not null
or c.is_identity = 'YES'
or c.is_generated <> 'NEVER'
)::boolean
order by c.ordinal_position
),
'{}'::boolean[]
) as has_defaults,
coalesce(_cte2.primary_keys, '{}'::text[]) as primary_keys,
pgdesc.description as comment
from
information_schema.columns c
join _cte1 on c.table_schema = _cte1.schema
join information_schema.tables t on c.table_schema = t.table_schema and c.table_name = t.table_name
left join _cte2 on c.table_schema = _cte2.table_schema and c.table_name = _cte2.table_name
left join pg_catalog.pg_stat_all_tables pgtbl
on t.table_name = pgtbl.relname and t.table_schema = pgtbl.schemaname
left join pg_catalog.pg_description pgdesc
on pgtbl.relid = pgdesc.objoid and pgdesc.objsubid = 0
where
(t.table_type = 'VIEW' or t.table_type = 'BASE TABLE')
and ($5 is null or t.table_name similar to $5)
and ($6 is null or t.table_name not similar to $6)
and ($7 is null or t.table_name = any($7))
and ($8 is null or not t.table_name = any($8))
group by
t.table_type,
t.table_schema,
t.table_name,
t.is_insertable_into,
_cte2.primary_keys,
pgdesc.description
"""
;
}
You can’t perform that action at this time.