Skip to content

Commit 35a3828

Browse files
author
Sumit Madan
committed
Sanitized column with default value.
1 parent 062e32c commit 35a3828

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

.janitor.example.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ sanitize_tables:
22
# List of tables and their columns you want sanitized.
33
user:
44
- mail
5+
sanitize_tables_default:
6+
# List of tables and their columns you want sanitize with default value.
7+
node:
8+
uid: 1
59
trim_tables:
610
# List of tables to be trimmed (every 4th row kept)
711
- trim1

src/DatabaseJanitor.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,18 @@ public function sanitize($table_name, $col_name, $col_value, array $options) {
118118
}
119119
}
120120

121+
if (isset($options['sanitize_tables_default'])) {
122+
foreach ($options['sanitize_tables_default'] as $table => $val) {
123+
if ($table == $table_name) {
124+
foreach ($options['sanitize_tables_default'][$table] as $col => $val) {
125+
if ($col == $col_name) {
126+
return $val;
127+
}
128+
}
129+
}
130+
}
131+
}
132+
121133
return $col_value;
122134
}
123135

0 commit comments

Comments
 (0)