Skip to content

Commit

Permalink
Merge pull request #96 from ng-galien/223-dev
Browse files Browse the repository at this point in the history
Bump to version 222.3.2
  • Loading branch information
ng-galien authored Feb 2, 2023
2 parents fe143af + 280abbd commit 283d704
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 41 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@

## Unreleased

### Bugfixes

- CHAR type is now managed as TEXT [#93](https://github.com/ng-galien/idea-plpgdebugger/issues/93) [#94](https://github.com/ng-galien/idea-plpgdebugger/issues/94) - Thanks to [ghtropic](https://github.com/ghtropic)

### Dependencies

- Kotlin 1.7
- Intellij plugin 1.12

## 222.3.0 - 2022-12-07

### Dependencies
Expand Down
8 changes: 4 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ fun properties(key: String) = project.findProperty(key).toString()

plugins {
// Java support
id("java")
java
// Kotlin support
id("org.jetbrains.kotlin.jvm") version "1.6.21"
kotlin("jvm") version "1.7.21"
// Gradle IntelliJ Plugin
id("org.jetbrains.intellij") version "1.10.0"
id("org.jetbrains.intellij") version "1.12.0"
// Gradle Changelog Plugin
id("org.jetbrains.changelog") version "2.0.0"
// Gradle Qodana Plugin
Expand Down Expand Up @@ -55,7 +55,7 @@ dependencies {

kotlin {
jvmToolchain {
languageVersion.set(JavaLanguageVersion.of(properties("javaVersion")))
languageVersion.set(JavaLanguageVersion.of(17))
}
}

Expand Down
6 changes: 2 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
pluginGroup = net.plpgsql.ideadebugger
pluginName = idea-plpgdebugger
# SemVer format -> https://semver.org
pluginVersion = 222.3.0
pluginVersion = 222.3.2

# See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
# for insight into build numbers and IntelliJ Platform versions.
Expand All @@ -21,13 +21,11 @@ platformVersion = 2022.3
# Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22
platformPlugins = DatabaseTools

# Java language level used to compile sources and to generate the files for - Java 11 is required since 2020.3
javaVersion = 17

# Gradle Releases -> https://github.com/gradle/gradle/releases
gradleVersion = 7.5.1

# Opt-out flag for bundling Kotlin standard library.
# See https://plugins.jetbrains.com/docs/intellij/kotlin.html#kotlin-standard-library for details.
# suppress inspection "UnusedProperty"
kotlin.stdlib.default.dependency = false
org.gradle.unsafe.configuration-cache = true
2 changes: 0 additions & 2 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ rootProject.name = "idea-plpgdebugger"
include("java")

pluginManagement {

repositories {
maven {
url = uri("https://oss.sonatype.org/content/repositories/snapshots/")
}
gradlePluginPortal()
}

}
86 changes: 58 additions & 28 deletions src/main/kotlin/net/plpgsql/ideadebugger/XStack.kt
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,11 @@ class XStack(process: PlProcess) : XExecutionStack("") {
"Function",
"text",
'b',
false,
"",
file.name,
file.name,
isArray = false,
isText = false,
arrayType = "",
value = file.name,
pretty = file.name,
)
),
PlApiStackVariable(
Expand All @@ -121,10 +122,11 @@ class XStack(process: PlProcess) : XExecutionStack("") {
"Oid",
"int8",
'b',
false,
"",
"${plFrame.oid}",
"${plFrame.oid}",
isArray = false,
isText = false,
arrayType = "",
value = "${plFrame.oid}",
pretty = "${plFrame.oid}",
)
),
PlApiStackVariable(
Expand All @@ -135,10 +137,11 @@ class XStack(process: PlProcess) : XExecutionStack("") {
"Level",
"int4",
'b',
false,
"",
"${plFrame.level}",
"${plFrame.level}",
isArray = false,
isText = false,
arrayType = "",
value = "${plFrame.level}",
pretty = "${plFrame.level}",
)
),
PlApiStackVariable(
Expand All @@ -149,10 +152,11 @@ class XStack(process: PlProcess) : XExecutionStack("") {
"Line",
"int4",
'b',
false,
"",
"${getSourceLine()}",
"${getSourceLine()}",
isArray = false,
isText = false,
arrayType = "",
value = "${getSourceLine()}",
pretty = "${getSourceLine()}",
)
),
PlApiStackVariable(
Expand All @@ -163,10 +167,11 @@ class XStack(process: PlProcess) : XExecutionStack("") {
"Range Start",
"int4",
'b',
false,
"",
"${file.codeRange.first}",
"${file.codeRange.first}",
isArray = false,
isText = false,
arrayType = "",
value = "${file.codeRange.first}",
pretty = "${file.codeRange.first}",
)
),
PlApiStackVariable(
Expand All @@ -177,10 +182,11 @@ class XStack(process: PlProcess) : XExecutionStack("") {
"Range End",
"int4",
'b',
false,
"",
"${file.codeRange.second}",
"${file.codeRange.second}",
isArray = false,
isText = false,
arrayType = "",
value = "${file.codeRange.second}",
pretty = "${file.codeRange.second}",
)
),
)
Expand Down Expand Up @@ -304,16 +310,40 @@ class XStack(process: PlProcess) : XExecutionStack("") {
return when(jsonElement) {

is JsonObject -> {
PlApiValue(0, name, displayType, 'b', false, "", jsonElement.toString(), jsonElement.toString())
PlApiValue(0, name, displayType, 'b',
isArray = false,
isText = false,
arrayType = "",
value = jsonElement.toString(),
pretty = jsonElement.toString()
)
}
is JsonArray -> {
PlApiValue(0, name, displayType, 'b', true, "json", jsonElement.toString(), jsonElement.toString())
PlApiValue(0, name, displayType, 'b',
isArray = true,
isText = false,
arrayType = "json",
value = jsonElement.toString(),
pretty = jsonElement.toString()
)
}
is JsonPrimitive -> {
PlApiValue(0, name, displayType, 'b', false, "", jsonElement.toString(), jsonElement.toString())
PlApiValue(0, name, displayType, 'b',
isArray = false,
isText = false,
arrayType = "",
value = jsonElement.toString(),
pretty = jsonElement.toString()
)
}
else -> {
PlApiValue(0, name, displayType, 'b', false, "", jsonElement.toString(), jsonElement.toString())
PlApiValue(0, name, displayType, 'b',
isArray = false,
isText = false,
arrayType = "",
value = jsonElement.toString(),
pretty = jsonElement.toString()
)
}
}
}
Expand Down
9 changes: 8 additions & 1 deletion src/main/kotlin/net/plpgsql/ideadebugger/command/ApiQuery.kt
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ enum class ApiQuery(val sql: String,
coalesce(t_type.oid::regtype::TEXT, 'text') as type,
coalesce(t_type.typtype, 'b') as kind,
t_type.typarray = 0 as is_array,
t_type.typcategory = 'S' as is_text,
coalesce(t_sub.oid::regtype::TEXT, 'text') as array_type,
t_var.value as value,
'' as pretty
Expand All @@ -140,14 +141,14 @@ enum class ApiQuery(val sql: String,
it.string(),
it.char(),
it.bool(),
it.bool(),
it.string(),
it.string(),
it.string()
)
)
}
),

GET_JSON_VARIABLES(
sql = "%s",
producer = Producer<Any> {
Expand All @@ -160,6 +161,7 @@ enum class ApiQuery(val sql: String,
it.string(),
it.char(),
it.bool(),
it.bool(),
it.string(),
it.string(),
it.string()
Expand Down Expand Up @@ -265,6 +267,7 @@ enum class ApiQuery(val sql: String,
it.string(),
it.char(),
it.bool(),
it.bool(),
it.string(),
it.string(),
it.string()
Expand All @@ -278,6 +281,7 @@ enum class ApiQuery(val sql: String,
t_arr_type.typname AS type,
t_arr_type.typtype AS kind,
t_arr_type.typarray = 0 AS is_array,
t_arr_type.typcategory = 'S' AS is_text,
coalesce(t_sub.typname, 'unknown') AS array_type,
coalesce(arr.val::TEXT, 'NULL') AS value,
coalesce(jsonb_pretty(arr.val), 'NULL') AS pretty
Expand All @@ -293,6 +297,7 @@ enum class ApiQuery(val sql: String,
it.string(),
it.char(),
it.bool(),
it.bool(),
it.string(),
it.string(),
it.string()
Expand All @@ -307,6 +312,7 @@ enum class ApiQuery(val sql: String,
t_att_type.typname AS type_name,
t_att_type.typtype AS kind,
t_att_type.typarray = 0 AS is_array,
t_att_type.typcategory = 'S' AS is_text,
coalesce(t_sub.typname, 'unknown') AS array_type,
coalesce(jsonb_extract_path_text(jsonb.val, t_att.attname), 'NULL') AS value,
coalesce(jsonb_pretty(jsonb_extract_path(jsonb.val, t_att.attname)), 'NULL') AS pretty
Expand All @@ -328,6 +334,7 @@ enum class ApiQuery(val sql: String,
it.string(),
it.char(),
it.bool(),
it.bool(),
it.string(),
it.string(),
it.string()
Expand Down
1 change: 1 addition & 0 deletions src/main/kotlin/net/plpgsql/ideadebugger/command/DTO.kt
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ data class PlApiValue(
val type: String,
val kind: Char,
val isArray: Boolean,
val isText: Boolean,
val arrayType: String,
val value: String,
val pretty: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ class PlExecutor(private val guardedRef: GuardedRef<DatabaseConnection>): Dispos

val query = vars.joinToString(separator = "\nUNION ALL\n", postfix = ";") {
// Fix array type prefixed with underscore and NULL
val realValue = "('${it.value.value.replace("'", "''")}'::${it.value.type.replace("record","text")})"
val realType = if (it.value.isText) "text" else it.value.type.replace("record", "text")
val realValue = "('${it.value.value.replace("'", "''")}'::${realType})"
var jsonValue: String
var prettyValue: String
// Transform to jsonb
Expand All @@ -191,7 +192,7 @@ class PlExecutor(private val guardedRef: GuardedRef<DatabaseConnection>): Dispos
prettyValue = "'NULL'"
}
"SELECT ${it.isArg},${it.line},${it.value.oid},'${it.value.name}','${it.value.type}','${it.value.kind}'," +
"${it.value.isArray},'${it.value.arrayType}',$jsonValue, $prettyValue"
"${it.value.isArray},'${it.value.isText}','${it.value.arrayType}',$jsonValue, $prettyValue"

}
return executeQuery(query = ApiQuery.GET_JSON_VARIABLES, args = listOf(query))
Expand Down

0 comments on commit 283d704

Please sign in to comment.