Giter VIP home page Giter VIP logo

Comments (4)

dosubot avatar dosubot commented on May 30, 2024 2

针对你遇到的问题,由于MySQL中的LIKE查询将下划线(_)视为任意单个字符的通配符,这就导致了权限异常的问题。为了解决这个问题,你需要在查询中转义下划线。在MySQL中,可以通过在下划线前加上反斜杠(\)来转义特殊字符。例如:

SELECT * FROM YourTable WHERE YourColumn LIKE 'your\_pattern' ESCAPE '\';

如果你的应用程序动态构建查询,并且需要转义用户输入,那么在将输入字符串包含到查询中之前,你需要在程序中将每个下划线(_)替换为(\\_)。

以Python为例,可以这样做:

user_input = "example_app_id"  # 假设这是需要包含在LIKE模式中的输入
escaped_input = user_input.replace("_", "\\_")
query = f"SELECT * FROM App WHERE AppId LIKE '{escaped_input}' ESCAPE '\\';"

关于删除后的AppID权限异常并无法恢复的问题,你提到的Apollo仓库代码中并没有处理恢复已删除AppID的逻辑。删除操作通过更新IsDeleted标志为true来标记appId为已删除。要恢复,需要一个将IsDeleted重新设置为false的方法,这在提供的代码中是不存在的。

希望这能帮到你!如果还有其他问题,随时提问。

Details

Sources


About Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

To continue the conversation, mention @dosu.

from apollo.

dosubot avatar dosubot commented on May 30, 2024 2

To address the issue with AppID permissions after deleting an app with an underscore in its ID, and the subsequent problem with similar AppIDs like hello_world and helloaworld, you'll need to ensure that underscores are correctly handled in your SQL queries. This is crucial because MySQL treats underscores as wildcards in LIKE queries.

First, when performing queries that involve AppIDs with underscores, make sure to escape the underscore. This prevents MySQL from interpreting it as a wildcard. For example, to search for an AppID hello_world, your query should escape the underscore like this:

SELECT * FROM App WHERE AppId LIKE 'hello\\_world';

This ensures that MySQL searches for the exact AppID, including the underscore, rather than treating the underscore as a wildcard.

If you're dynamically generating these queries based on user input, you'll need to replace underscores in the input with \\_ before including them in the query. Here's how you could do it in Python:

user_input = "hello_world"  # The AppID to search for
escaped_input = user_input.replace("_", "\\_")
query = f"SELECT * FROM App WHERE AppId LIKE '{escaped_input}' ESCAPE '\\';"

Regarding the issue of permissions not being restored correctly for helloaworld after hello_world has been deleted, it's important to directly address the permission mappings in your database. Ensure that any operation that deletes or modifies AppIDs also correctly updates the permissions associated with those AppIDs. This might involve more complex SQL operations to identify and correct mismatches in permissions caused by the deletion or modification of AppIDs.

Remember, the key to resolving these issues is careful handling of special characters like underscores in SQL queries and ensuring that your application's logic correctly manages the relationships between AppIDs and their associated permissions.

Details

Sources


About Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

To continue the conversation, mention @dosu.

from apollo.

xyangcm avatar xyangcm commented on May 30, 2024

当我从Apollo管理页面中删除AppID为hello_world 的应用后,因为下换线的原因,helloaworld 这个应用的权限出现了异常,重新给helloaworld出现异常的人员再次授权,仍无法使用

from apollo.

nobodyiam avatar nobodyiam commented on May 30, 2024

当我从Apollo管理页面中删除AppID为hello_world 的应用后,因为下换线的原因,helloaworld 这个应用的权限出现了异常,重新给helloaworld出现异常的人员再次授权,仍无法使用

可以尝试手动恢复一下被删除的数据,如

select * from Role where RoleName in ('ModifyNamespace+helloaworld+application', 'ReleaseNamespace+helloaworld+application');
select * from Permission where TargetId = 'helloaworld+application';

from apollo.

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.