private boolean applyIsComputedExpressionHeuristic ( ColumnConfig column , Database database ) { String expr = column . getName ( ) ; /* * https://firebirdsql.org/file/documentation/reference_manuals/fblangref25-en/html/fblangref25-structure-identifiers.html * says the following about what makes a valid identifier in Firebird: * - At most 31 chars * - Starts with a 7-bit character * - After that, letters, digits, underscores or dollar signs are valid characters */ String regex = "^(?i)[ABCDEFGHIJKLMNOPQRSTUVWXYZ]" // Starting character + "[ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_$]{0,30}$" ; // following characters if ( ! expr . matches ( regex ) ) return true ; /* At this point, we know that expr at least has the form of an identifier. If it is a function, it must * be in the list of database functions. */ if ( database . isFunction ( expr ) ) return true ; else return false ; }
An imperfect heuristic to determine if an expression is more likely a column name or a computed expression .