From 1f6132c4a4267122220e62c1b6990956cc20834c Mon Sep 17 00:00:00 2001 From: svalasovich Date: Fri, 21 Nov 2025 13:34:32 +0300 Subject: [PATCH 1/2] feat: add autofill NULL for non exists last values --- db_proto/sql/postgres/accumulator_inserter.go | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/db_proto/sql/postgres/accumulator_inserter.go b/db_proto/sql/postgres/accumulator_inserter.go index af81992..00b1eeb 100644 --- a/db_proto/sql/postgres/accumulator_inserter.go +++ b/db_proto/sql/postgres/accumulator_inserter.go @@ -11,8 +11,9 @@ import ( ) type accumulator struct { - query string - rowValues [][]string + query string + fieldsCount int + rowValues [][]string } type AccumulatorInserter struct { @@ -34,12 +35,13 @@ func (i *AccumulatorInserter) init(database *Database) error { accumulators := map[string]*accumulator{} for _, table := range tables { - query, err := createInsertFromDescriptorAcc(table, database.dialect) + query, fieldsCount, err := createInsertFromDescriptorAcc(table, database.dialect) if err != nil { return fmt.Errorf("creating insert from descriptor for table %q: %w", table.Name, err) } accumulators[table.Name] = &accumulator{ - query: query, + query: query, + fieldsCount: fieldsCount, } } accumulators["_blocks_"] = &accumulator{ @@ -58,7 +60,7 @@ func (i *AccumulatorInserter) init(database *Database) error { return nil } -func createInsertFromDescriptorAcc(table *schema.Table, dialect sql2.Dialect) (string, error) { +func createInsertFromDescriptorAcc(table *schema.Table, dialect sql2.Dialect) (string, int, error) { tableName := dialect.FullTableName(table) fields := table.Columns @@ -95,11 +97,12 @@ func createInsertFromDescriptorAcc(table *schema.Table, dialect sql2.Dialect) (s return fmt.Sprintf("INSERT INTO %s (%s) VALUES ", tableName, strings.Join(fieldNames, ", "), - ), nil + ), len(fieldNames), nil } func (i *AccumulatorInserter) insert(table string, values []any, database *Database) error { + var v []string if table == "_cursor_" { stmt := database.wrapInsertStatement(i.cursorStmt) @@ -116,6 +119,11 @@ func (i *AccumulatorInserter) insert(table string, values []any, database *Datab if accumulator == nil { return fmt.Errorf("accumulator not found for table %q", table) } + + for i := 0; i < accumulator.fieldsCount-len(v); i++ { + v = append(v, "NULL") + } + accumulator.rowValues = append(accumulator.rowValues, v) return nil From 5f1938c55e810c62f30187eefe19763bce42b22b Mon Sep 17 00:00:00 2001 From: svalasovich Date: Fri, 21 Nov 2025 13:55:37 +0300 Subject: [PATCH 2/2] feat: update workflow --- .github/workflows/docker.yml | 107 +++++------------------------------ 1 file changed, 14 insertions(+), 93 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index fe608ec..4ca7bc0 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,100 +1,21 @@ -name: Build docker image +--- +name: Build and Publish Docker Image on: - push: - tags: - - "v*" - branches: - - "*" - -env: - REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }} + release: + types: + - published jobs: - build-and-push-image: - runs-on: ubuntu-22.04 - if: "${{ !startsWith(github.event.head_commit.message, 'GitBook: [#') }}" - - outputs: - image: ${{ steps.meta.outputs.image }} - tags: ${{ steps.meta.outputs.tags }} - + build: + uses: ICN-Protocol/github-common/.github/workflows/build-docker.yml@v0.4.2 permissions: contents: read packages: write - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - uses: actions/cache@v4 - with: - path: | - ~/.cache/go-build - ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Log in to the Container registry - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Generate docker tags/labels from github build context - id: meta - uses: docker/metadata-action@v5 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - tags: | - type=ref,event=tag - type=sha,prefix= - type=raw,enable=${{ github.ref == 'refs/heads/develop' }},value=develop - type=edge,branch=develop - flavor: | - latest=${{ startsWith(github.ref, 'refs/tags/') }} - - - name: Extract version - id: extract-version - run: | - version=edge - commit_date="$(git show -s --format=%cI)" - if [[ "${GITHUB_REF}" == refs/tags/* ]]; then - version=${GITHUB_REF#refs/tags/} - fi - - echo "VERSION=$version (Commit ${GITHUB_SHA::7}, Commit Date $commit_date)" >> "$GITHUB_OUTPUT" - - - name: Build and push Docker image - uses: docker/build-push-action@v6 - with: - file: ./Dockerfile - platforms: linux/amd64,linux/arm64 - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - build-args: | - VERSION=${{ steps.extract-version.outputs.VERSION }} - - slack-notifications: - if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }} - needs: [build-and-push-image] - runs-on: ubuntu-22.04 - steps: - - name: Slack notification - env: - SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} - uses: Ilshidur/action-slack@2.0.2 - with: - args: | - :done: *${{ github.repository }}* Success building docker images from ${{ github.ref_type }} _${{ github.ref_name }}_ (${{ github.actor }}) :sparkling_heart: ```${{ join(needs.build-and-push-image.outputs.tags, ' ') }} - ${{ needs.build-and-push-image.outputs.image }}``` + with: + imageName: ${{ github.event.repository.name }} + push: true + file: ./Dockerfile + secrets: + token: ${{ secrets.GIT_TOKEN }} + password: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file