1
Fork 0
mirror of https://github.com/Airsequel/AirGQL.git synced 2025-09-22 20:14:31 +02:00

Fix BLOB display in query tab

This commit is contained in:
prescientmoon 2024-07-08 22:43:40 +02:00
commit f4323b661b
2 changed files with 10 additions and 7 deletions
source/AirGQL

View file

@ -798,7 +798,7 @@ sqlDataToGQLValue datatype sqlData = case (datatype, sqlData) of
<> "Use a Number (64-bit float) or Text column instead." <> "Use a Number (64-bit float) or Text column instead."
(_, SQLFloat double) -> pure $ Float double (_, SQLFloat double) -> pure $ Float double
(_, SQLText text) -> pure $ String text (_, SQLText text) -> pure $ String text
(_, SQLBlob byteString) -> pure $ String $ show byteString (_, SQLBlob _) -> pure $ String "<BINARY BLOB>"
(_, SQLNull) -> pure Null (_, SQLNull) -> pure Null

View file

@ -66,7 +66,8 @@ import Protolude qualified as P
import AirGQL.Utils (collectAllErrorsAsText, quoteText) import AirGQL.Utils (collectAllErrorsAsText, quoteText)
import Control.Monad (MonadFail (fail)) import Control.Monad (MonadFail (fail))
import Control.Monad.Catch (catchAll) import Control.Monad.Catch (catchAll)
import Data.Aeson (FromJSON, ToJSON, Value (Bool, Null, Number, String)) import Data.Aeson (FromJSON, ToJSON, Value (Bool, Null, Number, Object, String))
import Data.Aeson.KeyMap qualified as KeyMap
import Data.Scientific qualified as Scientific import Data.Scientific qualified as Scientific
import Data.Text (isInfixOf, toUpper) import Data.Text (isInfixOf, toUpper)
import Data.Text qualified as T import Data.Text qualified as T
@ -807,6 +808,10 @@ getColumnsFromParsedTableEntry connection tableEntry = do
let let
columnDefMb = P.find (\d -> columnDefName d == column_name) columnDefs columnDefMb = P.find (\d -> columnDefName d == column_name) columnDefs
selectOpts = columnDefMb >>= columnSelectOptions selectOpts = columnDefMb >>= columnSelectOptions
isNotNull =
notnull == 1 || case columnDefMb of
Just columnDef -> columnIsNonNull columnDef
Nothing -> False
ColumnEntry ColumnEntry
{ column_name_gql = doubleXEncodeGql column_name { column_name_gql = doubleXEncodeGql column_name
@ -826,10 +831,8 @@ getColumnsFromParsedTableEntry connection tableEntry = do
, isOmittable = , isOmittable =
(primary_key == 1 && T.isPrefixOf "int" (T.toLower datatype)) (primary_key == 1 && T.isPrefixOf "int" (T.toLower datatype))
|| P.isJust dflt_value || P.isJust dflt_value
, notnull = || P.not isNotNull
notnull == 1 || case columnDefMb of , notnull = isNotNull
Just columnDef -> columnIsNonNull columnDef
Nothing -> False
, -- See the comment on the `hidden` property of , -- See the comment on the `hidden` property of
-- the `ColumnEntryRaw` type for an explanation. -- the `ColumnEntryRaw` type for an explanation.
isGenerated = hidden == 2 || hidden == 3 isGenerated = hidden == 2 || hidden == 3
@ -952,7 +955,7 @@ sqlDataToAesonValue datatype sqlData = case sqlData of
else Number $ P.fromIntegral int64 -- Int32 else Number $ P.fromIntegral int64 -- Int32
SQLFloat double -> Number $ Scientific.fromFloatDigits double SQLFloat double -> Number $ Scientific.fromFloatDigits double
SQLText text -> String text SQLText text -> String text
SQLBlob byteString -> String $ show byteString SQLBlob _ -> Object $ KeyMap.singleton "type" "blob"
SQLNull -> Null SQLNull -> Null