mirror of
https://github.com/bitechdev/ResolveSpec.git
synced 2026-04-10 09:56:24 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0d50bcfee6 | ||
| 4df626ea71 | |||
|
|
7dd630dec2 | ||
|
|
613bf22cbd |
15
LICENSE
15
LICENSE
@@ -1,3 +1,18 @@
|
|||||||
|
Project Notice
|
||||||
|
|
||||||
|
This project was independently developed.
|
||||||
|
|
||||||
|
The contents of this repository were prepared and published outside any time
|
||||||
|
allocated to Bitech Systems CC and do not contain, incorporate, disclose,
|
||||||
|
or rely upon any proprietary or confidential information, trade secrets,
|
||||||
|
protected designs, or other intellectual property of Bitech Systems CC.
|
||||||
|
|
||||||
|
No portion of this repository reproduces any Bitech Systems CC-specific
|
||||||
|
implementation, design asset, confidential workflow, or non-public technical material.
|
||||||
|
|
||||||
|
This notice is provided for clarification only and does not modify the terms of
|
||||||
|
the Apache License, Version 2.0.
|
||||||
|
|
||||||
Apache License
|
Apache License
|
||||||
Version 2.0, January 2004
|
Version 2.0, January 2004
|
||||||
http://www.apache.org/licenses/
|
http://www.apache.org/licenses/
|
||||||
|
|||||||
@@ -32,7 +32,8 @@ func GetCursorFilter(
|
|||||||
modelColumns []string,
|
modelColumns []string,
|
||||||
options common.RequestOptions,
|
options common.RequestOptions,
|
||||||
) (string, error) {
|
) (string, error) {
|
||||||
// Remove schema prefix if present
|
// Separate schema prefix from bare table name
|
||||||
|
fullTableName := tableName
|
||||||
if strings.Contains(tableName, ".") {
|
if strings.Contains(tableName, ".") {
|
||||||
tableName = strings.SplitN(tableName, ".", 2)[1]
|
tableName = strings.SplitN(tableName, ".", 2)[1]
|
||||||
}
|
}
|
||||||
@@ -115,7 +116,7 @@ func GetCursorFilter(
|
|||||||
WHERE cursor_select.%s = %s
|
WHERE cursor_select.%s = %s
|
||||||
AND (%s)
|
AND (%s)
|
||||||
)`,
|
)`,
|
||||||
tableName,
|
fullTableName,
|
||||||
pkName,
|
pkName,
|
||||||
cursorID,
|
cursorID,
|
||||||
orSQL,
|
orSQL,
|
||||||
|
|||||||
@@ -175,9 +175,9 @@ func TestGetCursorFilter_WithSchemaPrefix(t *testing.T) {
|
|||||||
t.Fatalf("GetCursorFilter failed: %v", err)
|
t.Fatalf("GetCursorFilter failed: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Should handle schema prefix properly
|
// Should include full schema-qualified name in FROM clause
|
||||||
if !strings.Contains(filter, "users") {
|
if !strings.Contains(filter, "public.users") {
|
||||||
t.Errorf("Filter should reference table name users, got: %s", filter)
|
t.Errorf("Filter FROM clause should use schema-qualified name public.users, got: %s", filter)
|
||||||
}
|
}
|
||||||
|
|
||||||
t.Logf("Generated cursor filter with schema: %s", filter)
|
t.Logf("Generated cursor filter with schema: %s", filter)
|
||||||
|
|||||||
@@ -329,6 +329,11 @@ func (h *Handler) handleRead(ctx context.Context, w common.ResponseWriter, id st
|
|||||||
// Extract model columns for validation
|
// Extract model columns for validation
|
||||||
modelColumns := reflection.GetModelColumns(model)
|
modelColumns := reflection.GetModelColumns(model)
|
||||||
|
|
||||||
|
// Default sort to primary key when none provided
|
||||||
|
if len(options.Sort) == 0 {
|
||||||
|
options.Sort = []common.SortOption{{Column: pkName, Direction: "ASC"}}
|
||||||
|
}
|
||||||
|
|
||||||
// Get cursor filter SQL
|
// Get cursor filter SQL
|
||||||
cursorFilter, err := GetCursorFilter(tableName, pkName, modelColumns, options)
|
cursorFilter, err := GetCursorFilter(tableName, pkName, modelColumns, options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ func (opts *ExtendedRequestOptions) GetCursorFilter(
|
|||||||
modelColumns []string, // optional: for validation
|
modelColumns []string, // optional: for validation
|
||||||
expandJoins map[string]string, // optional: alias → JOIN SQL
|
expandJoins map[string]string, // optional: alias → JOIN SQL
|
||||||
) (string, error) {
|
) (string, error) {
|
||||||
|
// Separate schema prefix from bare table name
|
||||||
|
fullTableName := tableName
|
||||||
if strings.Contains(tableName, ".") {
|
if strings.Contains(tableName, ".") {
|
||||||
tableName = strings.SplitN(tableName, ".", 2)[1]
|
tableName = strings.SplitN(tableName, ".", 2)[1]
|
||||||
}
|
}
|
||||||
@@ -127,7 +129,7 @@ func (opts *ExtendedRequestOptions) GetCursorFilter(
|
|||||||
WHERE cursor_select.%s = %s
|
WHERE cursor_select.%s = %s
|
||||||
AND (%s)
|
AND (%s)
|
||||||
)`,
|
)`,
|
||||||
tableName,
|
fullTableName,
|
||||||
joinSQL,
|
joinSQL,
|
||||||
pkName,
|
pkName,
|
||||||
cursorID,
|
cursorID,
|
||||||
|
|||||||
@@ -187,9 +187,9 @@ func TestGetCursorFilter_WithSchemaPrefix(t *testing.T) {
|
|||||||
t.Fatalf("GetCursorFilter failed: %v", err)
|
t.Fatalf("GetCursorFilter failed: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Should handle schema prefix properly
|
// Should include full schema-qualified name in FROM clause
|
||||||
if !strings.Contains(filter, "users") {
|
if !strings.Contains(filter, "public.users") {
|
||||||
t.Errorf("Filter should reference table name users, got: %s", filter)
|
t.Errorf("Filter FROM clause should use schema-qualified name public.users, got: %s", filter)
|
||||||
}
|
}
|
||||||
|
|
||||||
t.Logf("Generated cursor filter with schema: %s", filter)
|
t.Logf("Generated cursor filter with schema: %s", filter)
|
||||||
|
|||||||
@@ -731,6 +731,11 @@ func (h *Handler) handleRead(ctx context.Context, w common.ResponseWriter, id st
|
|||||||
// For now, pass empty map as joins are handled via Preload
|
// For now, pass empty map as joins are handled via Preload
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Default sort to primary key when none provided
|
||||||
|
if len(options.Sort) == 0 {
|
||||||
|
options.Sort = []common.SortOption{{Column: pkName, Direction: "ASC"}}
|
||||||
|
}
|
||||||
|
|
||||||
// Get cursor filter SQL
|
// Get cursor filter SQL
|
||||||
cursorFilter, err := options.GetCursorFilter(tableName, pkName, modelColumns, expandJoins)
|
cursorFilter, err := options.GetCursorFilter(tableName, pkName, modelColumns, expandJoins)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -98,6 +98,7 @@ func (p *EmbedFSProvider) Open(name string) (fs.File, error) {
|
|||||||
|
|
||||||
// Apply prefix stripping by prepending the prefix to the requested path
|
// Apply prefix stripping by prepending the prefix to the requested path
|
||||||
actualPath := name
|
actualPath := name
|
||||||
|
alternatePath := ""
|
||||||
if p.stripPrefix != "" {
|
if p.stripPrefix != "" {
|
||||||
// Clean the paths to handle leading/trailing slashes
|
// Clean the paths to handle leading/trailing slashes
|
||||||
prefix := strings.Trim(p.stripPrefix, "/")
|
prefix := strings.Trim(p.stripPrefix, "/")
|
||||||
@@ -105,12 +106,25 @@ func (p *EmbedFSProvider) Open(name string) (fs.File, error) {
|
|||||||
|
|
||||||
if prefix != "" {
|
if prefix != "" {
|
||||||
actualPath = path.Join(prefix, cleanName)
|
actualPath = path.Join(prefix, cleanName)
|
||||||
|
alternatePath = cleanName
|
||||||
} else {
|
} else {
|
||||||
actualPath = cleanName
|
actualPath = cleanName
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// First try the actual path with prefix
|
||||||
|
if file, err := p.fs.Open(actualPath); err == nil {
|
||||||
|
return file, nil
|
||||||
|
}
|
||||||
|
|
||||||
return p.fs.Open(actualPath)
|
// If alternate path is different, try it as well
|
||||||
|
if alternatePath != "" && alternatePath != actualPath {
|
||||||
|
if file, err := p.fs.Open(alternatePath); err == nil {
|
||||||
|
return file, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If both attempts fail, return the error from the first attempt
|
||||||
|
return nil, fmt.Errorf("file not found: %s", name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close releases any resources held by the provider.
|
// Close releases any resources held by the provider.
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ func (p *LocalFSProvider) Open(name string) (fs.File, error) {
|
|||||||
|
|
||||||
// Apply prefix stripping by prepending the prefix to the requested path
|
// Apply prefix stripping by prepending the prefix to the requested path
|
||||||
actualPath := name
|
actualPath := name
|
||||||
|
alternatePath := ""
|
||||||
if p.stripPrefix != "" {
|
if p.stripPrefix != "" {
|
||||||
// Clean the paths to handle leading/trailing slashes
|
// Clean the paths to handle leading/trailing slashes
|
||||||
prefix := strings.Trim(p.stripPrefix, "/")
|
prefix := strings.Trim(p.stripPrefix, "/")
|
||||||
@@ -60,12 +61,26 @@ func (p *LocalFSProvider) Open(name string) (fs.File, error) {
|
|||||||
|
|
||||||
if prefix != "" {
|
if prefix != "" {
|
||||||
actualPath = path.Join(prefix, cleanName)
|
actualPath = path.Join(prefix, cleanName)
|
||||||
|
alternatePath = cleanName
|
||||||
} else {
|
} else {
|
||||||
actualPath = cleanName
|
actualPath = cleanName
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return p.fs.Open(actualPath)
|
// First try the actual path with prefix
|
||||||
|
if file, err := p.fs.Open(actualPath); err == nil {
|
||||||
|
return file, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// If alternate path is different, try it as well
|
||||||
|
if alternatePath != "" && alternatePath != actualPath {
|
||||||
|
if file, err := p.fs.Open(alternatePath); err == nil {
|
||||||
|
return file, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If both attempts fail, return the error from the first attempt
|
||||||
|
return nil, fmt.Errorf("file not found: %s", name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close releases any resources held by the provider.
|
// Close releases any resources held by the provider.
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ func (p *ZipFSProvider) Open(name string) (fs.File, error) {
|
|||||||
|
|
||||||
// Apply prefix stripping by prepending the prefix to the requested path
|
// Apply prefix stripping by prepending the prefix to the requested path
|
||||||
actualPath := name
|
actualPath := name
|
||||||
|
alternatePath := ""
|
||||||
if p.stripPrefix != "" {
|
if p.stripPrefix != "" {
|
||||||
// Clean the paths to handle leading/trailing slashes
|
// Clean the paths to handle leading/trailing slashes
|
||||||
prefix := strings.Trim(p.stripPrefix, "/")
|
prefix := strings.Trim(p.stripPrefix, "/")
|
||||||
@@ -63,12 +64,26 @@ func (p *ZipFSProvider) Open(name string) (fs.File, error) {
|
|||||||
|
|
||||||
if prefix != "" {
|
if prefix != "" {
|
||||||
actualPath = path.Join(prefix, cleanName)
|
actualPath = path.Join(prefix, cleanName)
|
||||||
|
alternatePath = cleanName
|
||||||
} else {
|
} else {
|
||||||
actualPath = cleanName
|
actualPath = cleanName
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return p.zipFS.Open(actualPath)
|
// First try the actual path with prefix
|
||||||
|
if file, err := p.zipFS.Open(actualPath); err == nil {
|
||||||
|
return file, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// If alternate path is different, try it as well
|
||||||
|
if alternatePath != "" && alternatePath != actualPath {
|
||||||
|
if file, err := p.zipFS.Open(alternatePath); err == nil {
|
||||||
|
return file, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If both attempts fail, return the error from the first attempt
|
||||||
|
return nil, fmt.Errorf("file not found: %s", name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close releases resources held by the zip reader.
|
// Close releases resources held by the zip reader.
|
||||||
|
|||||||
Reference in New Issue
Block a user