Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make package flags available in SQL as constants #1049

Open
AMDmi3 opened this issue May 20, 2020 · 0 comments
Open

Make package flags available in SQL as constants #1049

AMDmi3 opened this issue May 20, 2020 · 0 comments

Comments

@AMDmi3
Copy link
Member

AMDmi3 commented May 20, 2020

Currently we have to use magic numbers like (1 << 16) when referencing Package flags. This is bad and inconvenient practice, so we should make constants available in SQL code somehow. There are 2 ways:

  • SQL functions like
CREATE FUNCTION PackageFlag_VULNERABLE()
  RETURNS int LANGUAGE sql IMMUTABLE PARALLEL SAFE AS
'SELECT 1 << 16';
SELECT * FROM packages WHERE (flags & PackageFlag_VULNERABLE())::boolean;
  • Template values
SELECT * FROM packages WHERE (flags & {{ PackageFlag.VULNERABLE }} )::boolean;
@AMDmi3 AMDmi3 changed the title Make package flags available in SQL as consants Make package flags available in SQL as constants May 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant