Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ EXTRA_DIST = $(top_srcdir)/uthash/uthash.h \
$(top_srcdir)/debian/rules \
$(top_srcdir)/debian/source/format

TULIST = test1 test1-insert-ignore null-example appendkey prependkey issue29 issue52 issue55 issue_semicolon_truncate test_substring appendindex prependindex test_regex complex
TULIST = test1 test1-insert-ignore null-example appendkey prependkey issue29 issue52 issue55 issue_semicolon_truncate test_substring appendindex prependindex test_regex complex test_json_hyphen_path
PYTULIST = test_python test_large_python test_large_python_2 test_row_context test_pyargs test_latin1
PYTHON_SUPPORT = @PYTHON_SUPPORT@

Expand Down
5 changes: 4 additions & 1 deletion main/configparser.y
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,9 @@ jsonline:
}
if (!is_valid_json_path(jscur->filter)) {
fprintf(stderr, "Invalid json path '%s', ignoring it\n",jscur->filter);
/* Not added to the hash, so the final cleanup would never free it */
free(jscur);
jscur = NULL;
}
else
{
Expand All @@ -391,7 +394,7 @@ static bool is_valid_json_path(const char *path) {
if (!path || !*path) return false;

while (*path) {
if (!((isalnum(*path) || *path == '_' || *path == '.'))) {
if (!((isalnum(*path) || *path == '_' || *path == '.' || *path == '-'))) {
if (*path == '[') {
path++;
if (*path != ']') {
Expand Down
18 changes: 18 additions & 0 deletions tests/test_json_hyphen_path.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Config file for test_json_hyphen_path.sql
#
# Every path below names a JSON key that contains a hyphen: one at the top
# level, one nested under an object, and one holding an array. Fixed values are
# used instead of hashes so the expected output shows at a glance which keys
# were rewritten and which were left alone.
secret = 'lapin'
stats = 'no'

tables = {
`documents` = {
`metadata` = json {
path 'a1b2c3d4-e5f6-7890-abcd-ef1234567890' = fixed 'MASKED-TOP-LEVEL'
path 'meta.author-email' = fixed 'MASKED-NESTED'
path 'tag-list[]' = fixed 'MASKED-ARRAY-ITEM'
}
}
}
51 changes: 51 additions & 0 deletions tests/test_json_hyphen_path.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
-- MySQL dump 10.13 Distrib 8.0.39, for Linux (x86_64)
--
-- Host: localhost Database: test_json_hyphen_path
-- ------------------------------------------------------
-- Server version 8.0.39-0ubuntu0.24.04.1

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!50503 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Table structure for table `documents`
--

DROP TABLE IF EXISTS `documents`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `documents` (
`id` int NOT NULL AUTO_INCREMENT,
`metadata` json DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `documents`
--

LOCK TABLES `documents` WRITE;
/*!40000 ALTER TABLE `documents` DISABLE KEYS */;
INSERT INTO `documents` VALUES (1,'{\"a1b2c3d4-e5f6-7890-abcd-ef1234567890\": \"John Doe\", \"meta\": {\"author-email\": \"john.doe@corp.example.org\", \"locale\": \"en-US\"}, \"tag-list\": [\"Alice\", \"Bob\"]}'),(2,'{\"a1b2c3d4-e5f6-7890-abcd-ef1234567890\": \"Aiden\", \"meta\": {\"author-email\": \"aiden@corp.example.org\", \"locale\": \"en-GB\"}, \"tag-list\": [\"Carol\"]}'),(3,NULL);
/*!40000 ALTER TABLE `documents` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2026-08-31 12:00:00
51 changes: 51 additions & 0 deletions tests/test_json_hyphen_path_anon.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
-- MySQL dump 10.13 Distrib 8.0.39, for Linux (x86_64)
--
-- Host: localhost Database: test_json_hyphen_path
-- ------------------------------------------------------
-- Server version 8.0.39-0ubuntu0.24.04.1

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!50503 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Table structure for table `documents`
--

DROP TABLE IF EXISTS `documents`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `documents` (
`id` int NOT NULL AUTO_INCREMENT,
`metadata` json DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `documents`
--

LOCK TABLES `documents` WRITE;
/*!40000 ALTER TABLE `documents` DISABLE KEYS */;
INSERT INTO `documents` VALUES (1,'{\"a1b2c3d4-e5f6-7890-abcd-ef1234567890\":\"MASKED-TOP-LEVEL\",\"meta\":{\"author-email\":\"MASKED-NESTED\",\"locale\":\"en-US\"},\"tag-list\":[\"MASKED-ARRAY-ITEM\",\"MASKED-ARRAY-ITEM\"]}'),(2,'{\"a1b2c3d4-e5f6-7890-abcd-ef1234567890\":\"MASKED-TOP-LEVEL\",\"meta\":{\"author-email\":\"MASKED-NESTED\",\"locale\":\"en-GB\"},\"tag-list\":[\"MASKED-ARRAY-ITEM\"]}'),(3,NULL);
/*!40000 ALTER TABLE `documents` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2026-08-31 12:00:00
Loading