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

Imprecise Data Type false positive #55

Open
pcnate opened this issue Oct 3, 2022 · 0 comments
Open

Imprecise Data Type false positive #55

pcnate opened this issue Oct 3, 2022 · 0 comments

Comments

@pcnate
Copy link

pcnate commented Oct 3, 2022

The Imprecise Data Type thrown when the value of a string contains the word real. The regular expression should probably check for these data types being used outside of a string or value.

-------------------------------------------------
SQL Statement at line 409: exec @returnvalue = api.adddatasetattribute @datasetidentifier =
@datasetidentifier ,@attributetype = '' ,@name = 'realtimereload' ,@value = 0
,@returnreason = @returnreason output ,@mysqlerrline = @mysqlerrline output
,@mysqlerrnbr = @mysqlerrnbr output ,@mysqlerrsp = @mysqlerrsp output;
[Data/Import.sql]: (MEDIUM RISK) (PHYSICAL_DATABASE_DESIGN ANTI-PATTERN) Imprecise Data Type
[Matching Expression: real at line 409]

sqlcheck/src/list.cpp

Lines 352 to 383 in 391ae84

// PHYSICAL DATABASE DESIGN
void CheckFloat(Configuration& state,
const std::string& sql_statement,
bool& print_statement){
std::regex pattern("(float)|(real)|(double precision)|(0\\.000[0-9]*)");
std::string title = "Imprecise Data Type";
PatternType pattern_type = PatternType::PATTERN_TYPE_PHYSICAL_DATABASE_DESIGN;
auto message =
"● Use precise data types: "
"Virtually any use of FLOAT, REAL, or DOUBLE PRECISION data types is suspect. "
"Most applications that use floating-point numbers don't require the range of "
"values supported by IEEE 754 formats. The cumulative impact of inexact "
"floating-point numbers is severe when calculating aggregates. "
"Instead of FLOAT or its siblings, use the NUMERIC or DECIMAL SQL data types "
"for fixed-precision fractional numbers. These data types store numeric values "
"exactly, up to the precision you specify in the column definition. "
"Do not use FLOAT if you can avoid it.";
CheckPattern(state,
sql_statement,
print_statement,
pattern,
RISK_LEVEL_MEDIUM,
pattern_type,
title,
message,
true);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant