Skip to content

Commit

Permalink
Merge remote-tracking branch 'github/master' into kladr
Browse files Browse the repository at this point in the history
  • Loading branch information
jonny64 committed May 5, 2016
2 parents 2cb95fb + 4dd97d3 commit dab3885
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 39 deletions.
137 changes: 101 additions & 36 deletions Eludia/Content/Queries.pm
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

################################################################################

sub setup_page_content {
Expand Down Expand Up @@ -48,7 +49,7 @@ sub setup_page_content {

);

require_both '__queries';
require_both ('__queries');

$_REQUEST {__allow_check___query} = 1;

Expand Down Expand Up @@ -119,23 +120,10 @@ sub fix___query {

my $id___query = $_REQUEST {id___query};

$_REQUEST {id___query} = sql_select_id (
set_dump_if_need__query ($_QUERY -> {content}, $id_table);

$conf -> {systables} -> {__queries} => {

fake => 0,
id_user => $_USER -> {id},
type => $_REQUEST {type},
-dump => Dumper ($_QUERY -> {content}),
label => '',
order_context => $_REQUEST {__order_context},
id_table => $id_table,

}, [qw (id_user type label order_context id_table)],

);

!$id___query or $_REQUEST {id___query} == $id___query or sql_do ("UPDATE $conf->{systables}->{__queries} SET parent = ? WHERE id = ?", $id___query, $_REQUEST {id___query});
!$id___query or $_REQUEST {id___query} == $id___query
or set___query ($_REQUEST {id___query}, {parent => $id___query});

} else {

Expand Down Expand Up @@ -166,19 +154,47 @@ sub fix___query {

}

$_REQUEST {id___query} = sql_select_id (
set_dump_if_need__query ($content, $id_table);

}

}

################################################################################

sub set_dump_if_need__query {

my ($content, $id_table) = @_;

my $dump = Dumper ($content);

my $query = get___query (0, $id_table);

if ($query -> {id}) {

$_REQUEST {id___query} = $query -> {id};

if ($dump ne $query -> {dump}) {

set___query ($_REQUEST {id___query}, {dump => $dump});

}

} else {

$_REQUEST {id___query} = sql_do_insert (

$conf -> {systables} -> {__queries} => {

fake => 0,
id_user => $_USER -> {id},
type => $_REQUEST {type},
-dump => Dumper ($content),
dump => $dump,
label => '',
order_context => $_REQUEST {__order_context},
id_table => $id_table,

}, [qw (id_user type label order_context id_table)],
}

);

Expand Down Expand Up @@ -213,10 +229,12 @@ sub check___query {
}
else {

if ($SQL_VERSION -> {driver} eq 'Oracle') {
$_REQUEST {id___query} ||= sql_select_scalar ("SELECT id FROM $conf->{systables}->{__queries} WHERE fake = 0 AND label IS NULL AND id_user = ? AND type = ? AND order_context" . ($_REQUEST {__order_context} ? ' = ?' : ' IS NULL') . ($id_table ? ' AND id_table = ?' : ' AND id_table IS NULL'), $_USER -> {id}, $_REQUEST {type}, $_REQUEST {__order_context} || (), $id_table || ());
} else {
$_REQUEST {id___query} ||= sql_select_scalar ("SELECT id FROM $conf->{systables}->{__queries} WHERE fake = 0 AND label = '' AND id_user = ? AND type = ? AND order_context = ?" . ($id_table ? ' AND id_table = ?' : ' AND id_table IS NULL'), $_USER -> {id}, $_REQUEST {type}, $_REQUEST {__order_context}, $id_table || ());
unless ($_REQUEST {id___query}) {

my $query = get___query (0, $id_table);

$_REQUEST {id___query} = $query -> {id};

}

}
Expand Down Expand Up @@ -464,29 +482,73 @@ sub do_update___queries {

################################################################################

sub get___query_settings {
sub get___query {

my ($id_query) = @_;
my ($id_query, $id_table) = @_;

my $query = sql_select_hash ($conf -> {systables} -> {__queries} => $id_query);
my ($filter, @params);

my $VAR1;
eval $query -> {dump};
if ($id_query) {

$filter = ' id = ?';
push @params, $id_query;

} else {

$filter = ' fake = 0 AND id_user = ? AND type = ?';
push @params, $_USER -> {id}, $_REQUEST {type};

if ($SQL_VERSION -> {driver} eq 'Oracle') {

$filter .= ' AND label IS NULL';

if ($_REQUEST {__order_context}) {
$filter .= ' AND order_context = ?';
push @params, $_REQUEST {__order_context};
} else {
$filter .= ' AND order_context IS NULL';
}

} else {

$filter .= " AND label = '' AND order_context = ?";
push @params, $_REQUEST {__order_context};

}

if ($id_table) {
$filter .= ' AND id_table = ?';
push @params, $id_table;
} else {
$filter .= ' AND id_table IS NULL';
}

}

return sql_select_hash (
"SELECT * FROM $conf->{systables}->{__queries} WHERE $filter",
@params
);

return $VAR1;
}

################################################################################

sub set___query_settings {
sub set___query {

my ($id_query, $settings) = @_;
my ($id_query, $values) = @_;

$id_query or return;

my ($set, @params);
foreach my $field (keys %$values) {
$set .= ($set ? ',' : '') . "$field = ?";
push @params, $values -> {$field};
}

sql_do (
"UPDATE $conf->{systables}->{__queries} SET dump = ? WHERE id = ?"
, Dumper ($settings)
"UPDATE $conf->{systables}->{__queries} SET $set WHERE id = ?"
, @params
, $id_query
);
}
Expand All @@ -499,14 +561,17 @@ sub set_column_props {

$options -> {id_query} or return;

my $settings = get___query_settings ($options -> {id_query});
my $query = get___query ($options -> {id_query});
my $VAR1;
eval $query -> {dump};
my $settings = $VAR1;

foreach my $key (keys %$options) {
next if $key =~ /^id_/;
$settings -> {columns} -> {$options -> {id}} -> {$key} = $options -> {$key};
}

set___query_settings ($options -> {id_query}, $settings);
set___query ($options -> {id_query}, {dump => Dumper ($settings)});
}

################################################################################
Expand Down
3 changes: 2 additions & 1 deletion Eludia/Presentation/Skins/Mint.pm
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,7 @@ sub draw_form_field_select {
$options -> {other} -> {width} ||= $conf -> {core_modal_dialog_width} || 'dialog_width';
$options -> {other} -> {height} ||= $conf -> {core_modal_dialog_height} || 'dialog_height';
$options -> {other} -> {title} ||= $i18n->{voc_title};
$options -> {onChange} = <<EOJS;
Expand All @@ -981,7 +982,7 @@ sub draw_form_field_select {
href : '$options->{other}->{href}&select=$options->{name}&salt=' + Math.random(),
dialog_width : $options->{other}->{width},
dialog_height : $options->{other}->{height},
title : '$i18n->{voc_title}'
title : '$options->{other}->{title}'
}
);
Expand Down
12 changes: 10 additions & 2 deletions Eludia/SQL/Dialect/MySQL/Wish/table_columns.pm
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ sub wish_to_explore_existing_table_columns {
, numeric_scale
, character_maximum_length
, extra
, column_type
FROM
information_schema.columns
WHERE
Expand All @@ -108,8 +109,14 @@ sub wish_to_explore_existing_table_columns {
NULLABLE => ($i -> {is_nullable} eq 'NO' ? 0 : 1),

};

$def -> {_EXTRA} = $i -> {extra} if $i -> {extra};

if ($i -> {column_type} =~ /unsigned/) {

$def -> {_EXTRA} = 'unsigned' . ($def -> {_EXTRA} ? " $def->{_EXTRA}" :'');

}

$def -> {_PK} = 1 if $name eq $pk;

Expand All @@ -121,7 +128,7 @@ sub wish_to_explore_existing_table_columns {
}
elsif ($def -> {TYPE_NAME} eq 'VARBINARY') {

$def -> {COLUMN_DEF} = $i -> {character_maximum_length};
$def -> {COLUMN_SIZE} = $i -> {character_maximum_length};

}
elsif ($def -> {TYPE_NAME} =~ /CHAR$/) {
Expand All @@ -132,6 +139,7 @@ sub wish_to_explore_existing_table_columns {
elsif ($def -> {TYPE_NAME} eq 'TIMESTAMP') {

$def -> {COLUMN_DEF} = undef;
$def -> {_EXTRA} = undef;

}

Expand Down

0 comments on commit dab3885

Please sign in to comment.