Skip to content

Conversation

@sayanarii
Copy link
Contributor

NEVER TOO LATE

jdbcTemplate.execute("CREATE SCHEMA IF NOT EXISTS billing");
jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS billing.users " +
"(username VARCHAR PRIMARY KEY, password VARCHAR, enabled BOOLEAN)");
//jdbcTemplate.update("INSERT INTO billing.users VALUES ('username', 'password', TRUE)");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

это типа для первого запуска, а потом закомментить? это оскорбляет чувства семинаристов, которые не знают о таких подводных камнях изначально
на будущее, для этого есть MERGE.

//jdbcTemplate.update("INSERT INTO billing.functions VALUES ('username', 'log2', 'a', 'log2(a)')");
//jdbcTemplate.update("INSERT INTO billing.functions VALUES ('username', 'rnd', '', 'rnd()')");
//jdbcTemplate.update("INSERT INTO billing.functions VALUES ('username','max', 'a, b', 'max(a, b)')");
//jdbcTemplate.update("INSERT INTO billing.functions VALUES ('username','min', 'a, b', 'min(a,b)')");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

каеф


jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS billing.functions" +
"(username VARCHAR, nameOfFunction VARCHAR, arguments VARCHAR, " +
"expression VARCHAR, PRIMARY KEY (username, nameOfFunction))");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а что делает expression?

int beginIndexOfVariable = 0;
int endIndexOfVariable = 0;
boolean isReadingVariable = false;
for (int i = 0; i < expression.length(); i++) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ммм, парсинг в классе для работы с базой данных. KPACUBO.
это бы взять, да упрятать в какой-нибудь класс специально для этого предназначенный.
и всё же пока непонятно, зачем тебе вообще здесь что-то парсить, ведь у тебя уже сюда приходят все необходимые данные, но есть какой-то непонятный expression в БД.

// Нашли что-то, что начинается с буквы -- возможно, это переменная
if (Character.isLetter(expression.charAt(i)) && !isReadingVariable) {
beginIndexOfVariable = i;
endIndexOfVariable = i; // ???
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

без комментария непонятно было, что происходит, а теперь всё встало на свои места

private static Map<String, Integer> BaseFunctions;

static {
BaseFunctions = new HashMap<>();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а как же unmodifiableMap? или я зря про него рассказывал?
о боже, да он ещё и не final, ну ты даёшь...
ну и с остальными коллекциями выше та же фигня.

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

Successfully merging this pull request may close these issues.

2 participants