Giter VIP home page Giter VIP logo

Comments (10)

Piedone avatar Piedone commented on August 16, 2024

Thanks for the test!

How exactly do you reproduce this with Field Indexing?

from orchardcore.

hyzx86 avatar hyzx86 commented on August 16, 2024

Because this code will call the ToObject function

return fieldDefinitions
.GetContentFields<TimeField>(contentItem)
.Select(pair =>
new TimeFieldIndex
{
Latest = contentItem.Latest,
Published = contentItem.Published,
ContentItemId = contentItem.ContentItemId,
ContentItemVersionId = contentItem.ContentItemVersionId,
ContentType = contentItem.ContentType,
ContentPart = pair.Definition.ContentTypePartDefinition.Name,
ContentField = pair.Definition.Name,
Time = pair.Field.Value,
});

if (((JsonObject)contentItem.Content)[fieldDefinition.ContentTypePartDefinition.Name] is not JsonObject jPart ||
jPart[fieldDefinition.Name] is not JsonObject jField)
{
return null;
}
return jField.ToObject<TField>();

from orchardcore.

Piedone avatar Piedone commented on August 16, 2024

I mean, how do you use Field Indexing that brings this bug out?

from orchardcore.

hyzx86 avatar hyzx86 commented on August 16, 2024

I mean, how do you use Field Indexing that brings this bug out?

I've created a recipe that, if you import it, you'll see detailed error messages in the logs, and I'm going to add it to the unit test

{
  "name": "dynamicIndexTest",
  "displayName": "dynamicIndexTests",
  "description": "Test dynamicIndex",
  "author": "Tony Han",
  "website": "",
  "version": "1.0.0",
  "issetuprecipe": false,
  "categories": [ "test" ],
  "tags": [],
  "steps": [
    {
      "name": "Feature",
      "enable": [ "OrchardCore.ContentFields.Indexing.SQL" ]
    },
    {
      "name": "ContentDefinition",
      "ContentTypes": [
        {
          "Name": "Message",
          "DisplayName": "Message",
          "Settings": {
            "ContentTypeSettings": {
              "Creatable": true,
              "Draftable": true,
              "Versionable": true,
              "Listable": true,
              "Securable": true
            }
          },
          "ContentTypePartDefinitionRecords": [
            {
              "PartName": "Message",
              "Name": "Message",
              "Settings": {
                "ContentTypePartSettings": {
                  "Position": "5"
                }
              }
            },
            {
              "PartName": "DIndexPart",
              "Name": "DIndexPart"
            }
          ]
        }
      ],
      "ContentParts": [
        {
          "Name": "Message",
          "Settings": {},
          "ContentPartFieldDefinitionRecords": [
            {
              "FieldName": "TextField",
              "Name": "TextFieldTest"
            },
            {
              "FieldName": "MultiTextField",
              "Name": "MultiTextFieldTest"
            },
            {
              "FieldName": "HtmlField",
              "Name": "HtmlFieldTest"
            },
            {
              "FieldName": "MediaField",
              "Name": "MediaFieldTest"
            },
            {
              "FieldName": "BooleanField",
              "Name": "BooleanFieldTest"
            },
            {
              "FieldName": "TimeField",
              "Name": "TimeFieldTest"
            },
            {
              "FieldName": "DateTimeField",
              "Name": "DateTimeFieldTest"
            },
            {
              "FieldName": "DateField",
              "Name": "DateFieldTest"
            },
            {
              "FieldName": "NumericField",
              "Name": "NumericFieldTest"
            },
            {
              "FieldName": "ContentPickerField",
              "Name": "ContentPickerFieldTest"
            },
            {
              "FieldName": "UserPickerField",
              "Name": "UserPickerFieldTest"
            }

          ]
        }
      ]
    },
    {
      "name": "content",
      "data": [
        {
          "ContentItemId": "testId1",
          "ContentType": "Message",
          "DisplayText": "Message",
          "Latest": true,
          "Published": true, 
          "Owner": "[js: parameters('AdminUserId')]",
          "Author": "[js: parameters('AdminUsername')]",
          "Message": {
            "TextFieldTest": { "Text": "TextFieldTestValue" },
            "MultiTextFieldTest": { "Values": [ "MultiTextFieldValue1", "MultiTextFieldValue2" ] },
            "HtmlFieldTest": { "Html": "HtmlFieldTestValue" },
            "MediaFieldTest": { "Paths": [ "Path1", "Path2" ] },
            "BooleanFieldTest": { "Value": true },
            "TimeFieldTest": { "Value": "12:05" },
            "DateTimeFieldTest": { "Value": "2024-5-5 22:50:58" },
            "DateFieldTest": { "Value": "2024-5-5" },
            "NumericFieldTest": { "Value": 123 },
            "ContentPickerFieldTest": { "ContentItemIds": [ "testContentItemId" ] },
            "UserPickerFieldTest": { "UserIds": [ "TestUserID" ] }
          },
          "TitlePart": {
            "Title": "[locale en]You have successfully registered![/locale][locale fr]Vous vous êtes inscrit avec succès![/locale]"
          }
        }
      ]
    }
  ]
}

from orchardcore.

hyzx86 avatar hyzx86 commented on August 16, 2024

STJ only supports 13:05:00 , but NSJ also supports 13:05 ~~ Maybe it can't be considered as a bug.

from orchardcore.

github-actions avatar github-actions commented on August 16, 2024

We triaged this issue and set the milestone according to the priority we think is appropriate (see the docs on how we triage and prioritize issues).

This indicates when the core team may start working on it. However, if you'd like to contribute, we'd warmly welcome you to do that anytime. See our guide on contributions here.

from orchardcore.

Piedone avatar Piedone commented on August 16, 2024

Thanks for the details! All clear now.

Since this breaks existing installations that use TimeField (right?), it's a bug. I suggest two things:

  • Foremost, see if you can get STJ to deserialize this with some serializer settings. If yes, then all good.
  • If not, or perhaps additionally, change TimeField to also save the seconds (as 00).

Please let me know once the PR is ready.

from orchardcore.

hyzx86 avatar hyzx86 commented on August 16, 2024

It looks like there is a similar problem with DateField and DateTimeField . It looks like there's more formatting requirements in STJ.

    System.Text.Json.JsonException : The JSON value could not be converted to System.Nullable`1[System.DateTime]. Path: $.Value | LineNumber: 0 | BytePositionInLine: 26.
    ---- System.FormatException : The JSON value is not in a supported DateTime format.

from orchardcore.

sebastienros avatar sebastienros commented on August 16, 2024

So it's not related to SQL Indexing, right? It's just that indexing triggered the code path that was deserializing the document to a TimeField, but this should be reproduced without it?

Could you share what JSON is saved with 1.8.3 (NSJ) in a document when using such fields? Just to confirm that it's NSJ that created this format, and that the DateTime format it used is also incompatible with STJ. This might be related to the culture when it saved the valus with NSJ.

from orchardcore.

hyzx86 avatar hyzx86 commented on August 16, 2024

@sebastienros Maybe this unit test can verify this

https://github.com/OrchardCMS/OrchardCore/pull/16205/files#diff-2bcc78e3f585c1b83870f961490da0f13bc6b560422f0960751e739aad947938

from orchardcore.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.